2014-09-18 22:45:38 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
2014-09-20 15:39:28 +08:00
|
|
|
# zjunet.sh -- router for zjunet
|
2014-09-18 22:45:38 +08:00
|
|
|
#
|
2014-09-20 15:39:28 +08:00
|
|
|
# Copyright (C) 2014 Zeno Zeng <zenoofzeng@gmail.com>
|
2014-09-18 22:45:38 +08:00
|
|
|
#
|
2014-09-20 15:39:28 +08:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful, but
|
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
# General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with this program. If not, see
|
|
|
|
|
# <http://www.gnu.org/licenses/>.
|
2014-09-18 22:45:38 +08:00
|
|
|
|
|
|
|
|
BASEDIR=$(dirname $0)
|
2015-06-28 20:27:33 +08:00
|
|
|
MISCELLDIR="/usr/share/zjunet"
|
2014-09-18 22:45:38 +08:00
|
|
|
|
|
|
|
|
case "$1" in
|
2014-09-28 21:39:15 +08:00
|
|
|
route)
|
|
|
|
|
"${BASEDIR}/sudo.sh" "${BASEDIR}/route.sh"
|
|
|
|
|
;;
|
2014-09-19 23:06:14 +08:00
|
|
|
user)
|
2014-09-20 17:19:56 +08:00
|
|
|
"${BASEDIR}/user.sh" $2
|
2014-09-18 22:45:38 +08:00
|
|
|
;;
|
2014-09-28 21:39:15 +08:00
|
|
|
all)
|
|
|
|
|
"${BASEDIR}/wlan.sh" $2
|
2014-10-13 21:18:58 +08:00
|
|
|
"${BASEDIR}/vpn.sh" $2
|
2014-09-28 21:39:15 +08:00
|
|
|
;;
|
2014-09-18 22:45:38 +08:00
|
|
|
wlan)
|
2014-09-20 18:13:40 +08:00
|
|
|
"${BASEDIR}/wlan.sh" $2
|
2014-09-18 22:45:38 +08:00
|
|
|
;;
|
|
|
|
|
vpn)
|
2014-10-13 21:18:58 +08:00
|
|
|
"${BASEDIR}/vpn.sh" $2
|
2014-09-18 22:45:38 +08:00
|
|
|
;;
|
|
|
|
|
dns)
|
2014-09-20 17:19:56 +08:00
|
|
|
"${BASEDIR}/dns.sh"
|
2014-09-18 22:45:38 +08:00
|
|
|
;;
|
2015-06-28 20:19:12 +08:00
|
|
|
version|--version)
|
2015-06-28 20:27:33 +08:00
|
|
|
version_full=`cat "${MISCELLDIR}/VERSION"`
|
2015-06-28 20:19:12 +08:00
|
|
|
version=$(echo $version_full | sed 's/-.*//')
|
|
|
|
|
echo "zjunet version: $version (${version_full})"
|
2014-09-30 21:26:38 +08:00
|
|
|
;;
|
2014-09-20 20:20:11 +08:00
|
|
|
*)
|
|
|
|
|
cat <<EOF
|
2015-06-28 20:19:12 +08:00
|
|
|
zjunet: cli tool (VPN/WLAN/DNS) for network connection in ZJU
|
2014-09-20 20:20:11 +08:00
|
|
|
|
|
|
|
|
Usage: zjunet [ACTION]
|
|
|
|
|
|
|
|
|
|
Actions:
|
2014-09-26 14:14:53 +08:00
|
|
|
user
|
2014-09-26 15:16:05 +08:00
|
|
|
add Add a user
|
2014-09-26 14:14:53 +08:00
|
|
|
list List all enabled users
|
2014-10-15 16:24:20 +08:00
|
|
|
edit Edit a (enabled) user
|
2015-06-28 20:19:12 +08:00
|
|
|
* Note: to delete/disable a user, edit /etc/xl2tpd/xl2tpd.conf
|
2014-09-28 21:39:15 +08:00
|
|
|
all
|
|
|
|
|
connect(-c) Connect VPN & ZJUWLAN, and combine them using nexthop
|
|
|
|
|
disconnect(-d) Disconnect VPN & ZJUWLAN
|
2014-09-26 14:14:53 +08:00
|
|
|
vpn
|
|
|
|
|
connect(-c) Connect VPN and set up ip route
|
|
|
|
|
disconnect(-d) Disconnect VPN and reset ip route
|
|
|
|
|
wlan
|
2015-06-28 20:19:12 +08:00
|
|
|
connect(-c) Login ZJUWLAN using curl
|
|
|
|
|
disconnect(-d) Logout ZJUWLAN using curl
|
|
|
|
|
route Set up static route
|
|
|
|
|
dns [server] Test and set up DNS Server (default: 10.10.0.21)
|
|
|
|
|
version Display program version
|
2014-09-20 20:20:11 +08:00
|
|
|
EOF
|
|
|
|
|
;;
|
2014-09-18 22:45:38 +08:00
|
|
|
esac
|