From 81f093d79d675b98a3631768e2e4757a3c75ab41 Mon Sep 17 00:00:00 2001 From: Zeno Zeng Date: Sun, 21 Sep 2014 19:58:19 +0800 Subject: [PATCH] use global vars --- xl2tpd.sh | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/xl2tpd.sh b/xl2tpd.sh index 677cea5..b49396d 100755 --- a/xl2tpd.sh +++ b/xl2tpd.sh @@ -19,7 +19,14 @@ # along with this program. If not, see # . +LNS="10.5.1.9" 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() { @@ -43,22 +50,14 @@ xl2tpd_restart() { } 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 cat > $PPP_OPT_FILE < /dev/null xl2tpd-control connect ${LAC_NAME} > /dev/null @@ -119,12 +110,12 @@ case $1 in connect) xl2tpd_restart - xl2tpd_create_lac $2 $3 - connect $2 $3 + xl2tpd_create_lac + connect ;; disconnect) - disconnect $2 $3 + xl2tpd-control disconnect ${LAC_NAME} ;; esac