1
0
mirror of https://github.com/QSCTech/zjunet.git synced 2026-01-22 19:54:48 +08:00

Merge branch 'dev' of https://github.com/QSCTech/zjunet into dev

This commit is contained in:
Zeno Zeng 2014-10-13 21:22:10 +08:00
commit 4cfe165573
6 changed files with 21 additions and 15 deletions

View File

@ -53,7 +53,8 @@ if [ "${devs_count}" -eq "0" ]; then
ip route replace default via $gateway dev $dev ip route replace default via $gateway dev $dev
ip route ip route
return exit 0
#return
fi fi
ip route replace 10.5.1.0/24 via $gateway # for LNS ip route replace 10.5.1.0/24 via $gateway # for LNS

View File

@ -3,5 +3,5 @@
if [ "$(id -u)" -eq "0" ]; then if [ "$(id -u)" -eq "0" ]; then
"$@" "$@"
else else
sudo -u root "$@" sudo -u root "$@"
fi fi

View File

@ -35,7 +35,7 @@ edituser() {
password=$2 password=$2
echo $password > "$users_enabled/${username}" echo $password > "$users_enabled/${username}"
echo "[INFO] Disconnect VPN" echo "[INFO] Disconnect VPN"
"${BASEDIR}/sudo.sh" "${BASEDIR}/vpn.sh" disconnect "${BASEDIR}/vpn.sh" disconnect
echo "[INFO] Write to xl2tpd.conf" echo "[INFO] Write to xl2tpd.conf"
"${BASEDIR}/sudo.sh" "${BASEDIR}/xl2tpd.sh" adduser ${username} $password "${BASEDIR}/sudo.sh" "${BASEDIR}/xl2tpd.sh" adduser ${username} $password
echo "[INFO] Restart xl2tpd" echo "[INFO] Restart xl2tpd"

View File

@ -25,19 +25,19 @@ BASEDIR=$(dirname $0)
flush() { flush() {
# see also: https://github.com/QSCTech/zjunet/issues/39 # see also: https://github.com/QSCTech/zjunet/issues/39
ip route flush 10.5.1.5 "${BASEDIR}/sudo.sh" ip route flush 10.5.1.5
ip route flush 10.5.1.7 "${BASEDIR}/sudo.sh" ip route flush 10.5.1.7
ip route flush 10.5.1.9 "${BASEDIR}/sudo.sh" ip route flush 10.5.1.9
ip route flush 10.5.6.2 "${BASEDIR}/sudo.sh" ip route flush 10.5.6.2
} }
disconnect() { disconnect() {
users=$("${BASEDIR}/user.sh" getall) users=$("${BASEDIR}/user.sh" getall)
for username in $users; do for username in $users; do
echo "[INFO] Logout: ${username}" echo "[INFO] Logout: ${username}"
"${BASEDIR}/xl2tpd.sh" disconnect $username "${BASEDIR}/sudo.sh" "${BASEDIR}/xl2tpd.sh" disconnect $username
done done
"${BASEDIR}/route.sh" "${BASEDIR}/sudo.sh" "${BASEDIR}/route.sh"
} }
connect() { connect() {
@ -47,11 +47,13 @@ connect() {
for username in $users; do for username in $users; do
password=$("${BASEDIR}/user.sh" getpwd $username) password=$("${BASEDIR}/user.sh" getpwd $username)
echo "[INFO] Login using ${username}" echo "[INFO] Login using ${username}"
"${BASEDIR}/xl2tpd.sh" connect $username $password "${BASEDIR}/sudo.sh" "${BASEDIR}/xl2tpd.sh" connect $username $password
echo ------ flush
flush flush
echo ------ febd
done done
"${BASEDIR}/route.sh" "${BASEDIR}/sudo.sh" "${BASEDIR}/route.sh"
} }
##################################### #####################################

View File

@ -18,6 +18,8 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see # along with this program. If not, see
# <http://www.gnu.org/licenses/>. # <http://www.gnu.org/licenses/>.
#
# RUN AS ROOT! >..< ~~ / by xero ~~~ ararararar ~~~~
LNS="10.5.1.9" LNS="10.5.1.9"
L2TPD_CFG_FILE=/etc/xl2tpd/xl2tpd.conf L2TPD_CFG_FILE=/etc/xl2tpd/xl2tpd.conf
@ -78,7 +80,7 @@ xl2tpd_restart() {
} }
xl2tpd_create_lac() { xl2tpd_create_lac() {
touch $PPP_LOG_FILE #touch $PPP_LOG_FILE
cat > $PPP_OPT_FILE <<EOF cat > $PPP_OPT_FILE <<EOF
noauth noauth
@ -122,10 +124,11 @@ connect() {
echo -n > $PPP_LOG_FILE echo -n > $PPP_LOG_FILE
prev_count=$(ip addr show | grep 'inet.*ppp' | grep ' 10.5.' | wc -l) prev_count=$(ip addr show | grep 'inet.*ppp' | grep ' 10.5.' | wc -l)
echo $LOG_FILE
for i in $(seq 0 10000); do 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 tail $PPP_LOG_FILE >> $LOG_FILE
if [ $(tail $PPP_LOG_FILE | grep 'Connection terminated' | wc -l) -ne 0 ] if [ $(tail $PPP_LOG_FILE | grep 'Connection terminated' | wc -l) -ne 0 ]
then then

View File

@ -29,13 +29,13 @@ case "$1" in
;; ;;
all) all)
"${BASEDIR}/wlan.sh" $2 "${BASEDIR}/wlan.sh" $2
"${BASEDIR}/sudo.sh" "${BASEDIR}/vpn.sh" $2 "${BASEDIR}/vpn.sh" $2
;; ;;
wlan) wlan)
"${BASEDIR}/wlan.sh" $2 "${BASEDIR}/wlan.sh" $2
;; ;;
vpn) vpn)
"${BASEDIR}/sudo.sh" "${BASEDIR}/vpn.sh" $2 "${BASEDIR}/vpn.sh" $2
;; ;;
dns) dns)
"${BASEDIR}/dns.sh" "${BASEDIR}/dns.sh"