diff --git a/lib/vpn.sh b/lib/vpn.sh index 0ecc926..c39efa9 100755 --- a/lib/vpn.sh +++ b/lib/vpn.sh @@ -60,6 +60,9 @@ connect() { # ##################################### +# start xl2tpd if not +"${BASEDIR}/sudo.sh" "${BASEDIR}/xl2tpd.sh" trystart + case "$1" in -d) diff --git a/lib/xl2tpd.sh b/lib/xl2tpd.sh index 08c19a9..ea8163c 100755 --- a/lib/xl2tpd.sh +++ b/lib/xl2tpd.sh @@ -58,13 +58,6 @@ xl2tpd_start() { type systemctl >/dev/null 2>&1 && { systemctl xl2tpd start } -} - -xl2tpd_restart() { - - xl2tpd_stop - rm -f ${XL2TPD_CONTROL_FILE} - xl2tpd_start # wait until ready for i in $(seq 0 10); do @@ -79,6 +72,20 @@ xl2tpd_restart() { exit 1 } +xl2tpd_trystart() { + if [ -e ${XL2TPD_CONTROL_FILE} ]; then + echo "[INFO] xl2tpd ready." + else + xl2tpd_start + fi +} + +xl2tpd_restart() { + xl2tpd_stop + rm -f ${XL2TPD_CONTROL_FILE} + xl2tpd_start +} + xl2tpd_create_lac() { #touch $PPP_LOG_FILE @@ -164,6 +171,11 @@ case $1 in xl2tpd_restart ;; + trystart) + # will start unless already started + xl2tpd_trystart + ;; + adduser) xl2tpd_create_lac ;;