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

83 lines
2.5 KiB
Bash
Raw Normal View History

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)
2019-08-12 17:58:43 +08:00
MISCELLDIR="$BASEDIR/../../share/zjunet"
2014-09-18 22:45:38 +08:00
case "$1" in
r|route)
2014-09-28 21:39:15 +08:00
"${BASEDIR}/sudo.sh" "${BASEDIR}/route.sh"
;;
u|user)
2014-09-20 17:19:56 +08:00
"${BASEDIR}/user.sh" $2
2014-09-18 22:45:38 +08:00
;;
a|all)
2014-09-28 21:39:15 +08:00
"${BASEDIR}/wlan.sh" $2
2014-10-13 21:18:58 +08:00
"${BASEDIR}/vpn.sh" $2
2014-09-28 21:39:15 +08:00
;;
w|wlan)
2014-09-20 18:13:40 +08:00
"${BASEDIR}/wlan.sh" $2
2014-09-18 22:45:38 +08:00
;;
v|vpn)
2014-10-13 21:18:58 +08:00
"${BASEDIR}/vpn.sh" $2
2014-09-18 22:45:38 +08:00
;;
d|dns)
2015-06-30 00:21:01 +08:00
"${BASEDIR}/dns.sh" $2
2014-09-18 22:45:38 +08:00
;;
-v|version|--version)
2015-06-28 20:27:33 +08:00
version_full=`cat "${MISCELLDIR}/VERSION"`
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
zjunet: CLI tool (VPN/WLAN/DNS) for network connection in ZJU
2014-09-20 20:20:11 +08:00
Usage: zjunet [ACTION]
Actions:
user, u
add Add a user
list List all enabled users
edit Edit a (enabled) user
* Note: to delete/disable a user, edit /etc/xl2tpd/xl2tpd.conf
all, a
connect, -c Connect VPN & ZJUWLAN, and combine them using nexthop
disconnect, -d Disconnect VPN & ZJUWLAN
vpn, v
connect, -c Connect VPN and set up ip route
disconnect, -d Disconnect VPN and reset ip route
wlan, w
connect, -c Login ZJUWLAN using curl
disconnect, -d Logout ZJUWLAN using curl
disable Disable WLAN capability
route, r Set up static route
dns [ip], d [ip] Test and set up DNS Server (default: 10.10.0.21)
version, -v Display program version
Example:
zjunet user add Add a new user
zjunet vpn -c Connect VPN
zjunet vpn -d Disconnect VPN
zjunet wlan disable Completely disable WLAN capatibility
2014-09-20 20:20:11 +08:00
EOF
;;
2014-09-18 22:45:38 +08:00
esac