mirror of
https://github.com/QSCTech/zjunet.git
synced 2026-01-22 19:54:48 +08:00
use global vars
This commit is contained in:
parent
9697557817
commit
81f093d79d
33
xl2tpd.sh
33
xl2tpd.sh
@ -19,7 +19,14 @@
|
|||||||
# along with this program. If not, see
|
# along with this program. If not, see
|
||||||
# <http://www.gnu.org/licenses/>.
|
# <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
LNS="10.5.1.9"
|
||||||
PPP_LOG_FILE=/var/log/zjuvpn
|
PPP_LOG_FILE=/var/log/zjuvpn
|
||||||
|
L2TPD_CFG_FILE=/etc/xl2tpd/xl2tpd.conf
|
||||||
|
|
||||||
|
USERNAME=$2
|
||||||
|
PASSWORD=$3
|
||||||
|
LAC_NAME=zju-l2tp-${USERNAME}
|
||||||
|
PPP_OPT_FILE=/etc/ppp/peers/${LAC_NAME}
|
||||||
|
|
||||||
xl2tpd_restart() {
|
xl2tpd_restart() {
|
||||||
|
|
||||||
@ -43,22 +50,14 @@ xl2tpd_restart() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
xl2tpd_create_lac() {
|
xl2tpd_create_lac() {
|
||||||
username=$1
|
|
||||||
password=$2
|
|
||||||
|
|
||||||
LNS="10.5.1.9"
|
|
||||||
LAC_NAME=zjuvpn-${username}
|
|
||||||
PPP_OPT_FILE=/etc/ppp/peers/${LAC_NAME}
|
|
||||||
L2TPD_CFG_FILE=/etc/xl2tpd/xl2tpd.conf
|
|
||||||
|
|
||||||
touch $PPP_LOG_FILE
|
touch $PPP_LOG_FILE
|
||||||
|
|
||||||
cat > $PPP_OPT_FILE <<EOF
|
cat > $PPP_OPT_FILE <<EOF
|
||||||
noauth
|
noauth
|
||||||
linkname $LAC_NAME
|
linkname $LAC_NAME
|
||||||
logfile $PPP_LOG_FILE
|
logfile $PPP_LOG_FILE
|
||||||
name $username
|
name $USERNAME
|
||||||
password $password
|
password $PASSWORD
|
||||||
EOF
|
EOF
|
||||||
chmod 600 $PPP_OPT_FILE
|
chmod 600 $PPP_OPT_FILE
|
||||||
|
|
||||||
@ -80,15 +79,7 @@ EOF
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect() {
|
|
||||||
username=$1
|
|
||||||
LAC_NAME=zjuvpn-$1
|
|
||||||
xl2tpd-control disconnect ${LAC_NAME}
|
|
||||||
}
|
|
||||||
|
|
||||||
connect() {
|
connect() {
|
||||||
username=$1
|
|
||||||
LAC_NAME=zjuvpn-$1
|
|
||||||
xl2tpd-control disconnect ${LAC_NAME} > /dev/null
|
xl2tpd-control disconnect ${LAC_NAME} > /dev/null
|
||||||
xl2tpd-control connect ${LAC_NAME} > /dev/null
|
xl2tpd-control connect ${LAC_NAME} > /dev/null
|
||||||
|
|
||||||
@ -119,12 +110,12 @@ case $1 in
|
|||||||
|
|
||||||
connect)
|
connect)
|
||||||
xl2tpd_restart
|
xl2tpd_restart
|
||||||
xl2tpd_create_lac $2 $3
|
xl2tpd_create_lac
|
||||||
connect $2 $3
|
connect
|
||||||
;;
|
;;
|
||||||
|
|
||||||
disconnect)
|
disconnect)
|
||||||
disconnect $2 $3
|
xl2tpd-control disconnect ${LAC_NAME}
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user