From 41052944474bb91c40b4a9199a6bc9cbba5c5cd6 Mon Sep 17 00:00:00 2001 From: Xero Essential Date: Mon, 13 Oct 2014 21:18:58 +0800 Subject: [PATCH] Bug fix : $home bug on fedora --- lib/route.sh | 3 ++- lib/sudo.sh | 2 +- lib/user.sh | 2 +- lib/vpn.sh | 18 ++++++++++-------- lib/xl2tpd.sh | 7 +++++-- lib/zjunet.sh | 4 ++-- 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/lib/route.sh b/lib/route.sh index 6fe24f5..02fe88e 100755 --- a/lib/route.sh +++ b/lib/route.sh @@ -53,7 +53,8 @@ if [ "${devs_count}" -eq "0" ]; then ip route replace default via $gateway dev $dev ip route - return + exit 0 + #return fi ip route replace 10.5.1.0/24 via $gateway # for LNS diff --git a/lib/sudo.sh b/lib/sudo.sh index 51b74ca..7093129 100755 --- a/lib/sudo.sh +++ b/lib/sudo.sh @@ -3,5 +3,5 @@ if [ "$(id -u)" -eq "0" ]; then "$@" else - sudo -u root "$@" + sudo -u root "$@" fi diff --git a/lib/user.sh b/lib/user.sh index bfba0a5..48e44c3 100755 --- a/lib/user.sh +++ b/lib/user.sh @@ -35,7 +35,7 @@ edituser() { password=$2 echo $password > "$users_enabled/${username}" echo "[INFO] Disconnect VPN" - "${BASEDIR}/sudo.sh" "${BASEDIR}/vpn.sh" disconnect + "${BASEDIR}/vpn.sh" disconnect echo "[INFO] Write to xl2tpd.conf" "${BASEDIR}/sudo.sh" "${BASEDIR}/xl2tpd.sh" adduser ${username} $password echo "[INFO] Restart xl2tpd" diff --git a/lib/vpn.sh b/lib/vpn.sh index 7a3c9a1..1f20295 100755 --- a/lib/vpn.sh +++ b/lib/vpn.sh @@ -25,19 +25,19 @@ BASEDIR=$(dirname $0) flush() { # see also: https://github.com/QSCTech/zjunet/issues/39 - ip route flush 10.5.1.5 - ip route flush 10.5.1.7 - ip route flush 10.5.1.9 - ip route flush 10.5.6.2 + "${BASEDIR}/sudo.sh" ip route flush 10.5.1.5 + "${BASEDIR}/sudo.sh" ip route flush 10.5.1.7 + "${BASEDIR}/sudo.sh" ip route flush 10.5.1.9 + "${BASEDIR}/sudo.sh" ip route flush 10.5.6.2 } disconnect() { users=$("${BASEDIR}/user.sh" getall) for username in $users; do echo "[INFO] Logout: ${username}" - "${BASEDIR}/xl2tpd.sh" disconnect $username + "${BASEDIR}/sudo.sh" "${BASEDIR}/xl2tpd.sh" disconnect $username done - "${BASEDIR}/route.sh" + "${BASEDIR}/sudo.sh" "${BASEDIR}/route.sh" } connect() { @@ -47,11 +47,13 @@ connect() { for username in $users; do password=$("${BASEDIR}/user.sh" getpwd $username) echo "[INFO] Login using ${username}" - "${BASEDIR}/xl2tpd.sh" connect $username $password + "${BASEDIR}/sudo.sh" "${BASEDIR}/xl2tpd.sh" connect $username $password + echo ------ flush flush + echo ------ febd done - "${BASEDIR}/route.sh" + "${BASEDIR}/sudo.sh" "${BASEDIR}/route.sh" } ##################################### diff --git a/lib/xl2tpd.sh b/lib/xl2tpd.sh index cabf566..af67e14 100755 --- a/lib/xl2tpd.sh +++ b/lib/xl2tpd.sh @@ -18,6 +18,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see # . +# +# RUN AS ROOT! >..< ~~ / by xero ~~~ ararararar ~~~~ LNS="10.5.1.9" L2TPD_CFG_FILE=/etc/xl2tpd/xl2tpd.conf @@ -78,7 +80,7 @@ xl2tpd_restart() { } xl2tpd_create_lac() { - touch $PPP_LOG_FILE + #touch $PPP_LOG_FILE cat > $PPP_OPT_FILE < $PPP_LOG_FILE prev_count=$(ip addr show | grep 'inet.*ppp' | grep ' 10.5.' | wc -l) + echo $LOG_FILE for i in $(seq 0 10000); do - tail $PPP_LOG_FILE + tail $PPP_LOG_FILE >> /home/xero/tmp/ttttt tail $PPP_LOG_FILE >> $LOG_FILE if [ $(tail $PPP_LOG_FILE | grep 'Connection terminated' | wc -l) -ne 0 ] then diff --git a/lib/zjunet.sh b/lib/zjunet.sh index d443722..516fec4 100755 --- a/lib/zjunet.sh +++ b/lib/zjunet.sh @@ -29,13 +29,13 @@ case "$1" in ;; all) "${BASEDIR}/wlan.sh" $2 - "${BASEDIR}/sudo.sh" "${BASEDIR}/vpn.sh" $2 + "${BASEDIR}/vpn.sh" $2 ;; wlan) "${BASEDIR}/wlan.sh" $2 ;; vpn) - "${BASEDIR}/sudo.sh" "${BASEDIR}/vpn.sh" $2 + "${BASEDIR}/vpn.sh" $2 ;; dns) "${BASEDIR}/dns.sh"