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

Update README and add disable WLAN function

This commit is contained in:
Wu Yufei 2019-08-30 23:18:52 +08:00
parent 2576d68dd0
commit 8f0095c8fe
No known key found for this signature in database
GPG Key ID: 226E1C0EDF292D66
5 changed files with 142 additions and 54 deletions

View File

@ -26,37 +26,60 @@ Command Line Scripts for ZJU (VPN / WLAN / DNS)
- `dig` (Different package on different platform)
## Install
## Installation
If you meet any problem during or after the installation, check Troubleshooting section below in this documentation.
### Debian / Ubuntu (deb)
#### Install .deb package directly
1. Configure ZJU mirrors using [浙大源配置生成器](https://mirrors.zju.edu.cn/#generator).
2. Run these command.
Download .deb package from [Release Page](https://github.com/QSCTech/zjunet/releases),
Click or run `sudo apt-get install ./zjunet_<version>_all.deb` to install.
``` bash
curl https://dl.zjuqsc.com/linux/qsc.public.key | sudo apt-key add -
curl https://dl.zjuqsc.com/linux/debian/qsc.list | sudo tee /etc/apt/sources.list.d/qsc.list
sudo apt-get update
sudo apt-get install zjunet
```
3. The installation has completed.
4. If you are setting up a server, we suggest you run `zjunet wlan disable` to disable WLAN capability.
### Fedora / CentOS (rpm)
#### Install .rpm package directly
1. Configure ZJU mirrors using [浙大源配置生成器](https://mirrors.zju.edu.cn/#generator).
2. Configure [EPEL of ZJU mirrors](https://mirrors.zju.edu.cn/epel/) (Taking CentOS installation as an example)
1. Run `yum install epel-release` to install EPEL.
2. Edit `/etc/yum.repos.d/epel.repo` , uncomment lines begin with `#baseurl=` (Remove leading `#` sign) and comment lines begin with `mirrorlist=` (Prepend `#` sign)
3. Edit `/etc/yum.repos.d/epel.repo` , replace `https://download.fedoraproject.org/pub` with `https://mirrors.zju.edu.cn` .
Download .rpm package from [Release Page](https://github.com/QSCTech/zjunet/releases),
Click or run `sudo yum localinstall zjunet-<version>.noarch.rpm` to install.
3. Run these command.
**ATTENTION** In CentOS 7, *xl2tpd* requires epel.
```bash
curl https://dl.zjuqsc.com/linux/qsc.public.key | sudo tee /etc/pki/rpm-gpg/RPM-GPG-KEY-QSC-COMP66
curl https://dl.zjuqsc.com/linux/yum/qsc.repo | sudo tee /etc/yum.repos.d/qsc.repo
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-QSC-COMP66
sudo yum install zjunet
```
4. The installation has completed.
5. If you are setting up a server, we suggest you run `zjunet wlan disable` to disable WLAN capability.
### OpenWrt (opk)
Download .opk package from [Release Page](https://github.com/QSCTech/zjunet/releases) (onto your router),
Run `opkg install ./zjunet_<version>_all.opk`.
### Other linux (Source Code)
### Other Linux (Build from source code)
```bash
xl2tpd -v; curl -V; dig -v # Check installation of dependencies. There should be 3 version numbers.
# Under proper directory
git clone https://github.com/QSCTech/zjunet.git
cd zjunet
sudo ./install.sh
# If update is necessary, run `git pull` and `sudo ./install.sh`
# If you are setting up a server, we suggest you run `zjunet wlan disable` to disable WLAN capability.
```
**ATTENTION** Requirement check will **NOT** be done running `./install.sh`.

View File

@ -26,42 +26,82 @@
## 安装
根据发行版的不同,安装方式略有区别。为了更好的为您提供服务,建议您从求是潮网站的仓库下载。
(求是潮网站在校内也可以访问,安装时不需要先从仓库手动下载。)
考虑到需要安装 zjunet 的机器通常没有办法访问外网,建议配合 [浙大源](https://mirrors.zju.edu.cn/) 安装。
下面将按照不同的发行版分别列出安装步骤。如果你在安装前后遇到任何问题,请向下浏览本文件的“疑难解答”部分。
### Debian / Ubuntu (deb)
#### 直接安装 deb 包
1. 使用 [浙大源配置生成器](https://mirrors.zju.edu.cn/#generator) 生成需要的浙大源配置,并按照提示将 `/etc/apt/sources.list` 替换为显示的内容。
2. 依次输入并执行下列命令:
从 [Releases 页](https://github.com/QSCTech/zjunet/releases) 下载 deb 包,
双击安装或运行 `sudo apt-get install ./zjunet_版本_all.deb`
``` bash
curl https://dl.zjuqsc.com/linux/qsc.public.key | sudo apt-key add -
curl https://dl.zjuqsc.com/linux/debian/qsc.list | sudo tee /etc/apt/sources.list.d/qsc.list
sudo apt-get update
sudo apt-get install zjunet
```
3. 安装结束!您可以输入 `zjunet version` 查看安装的版本,输入 `zjunet usage` 查看用法。
4. 如果你是服务器用户,建议运行 `zjunet wlan disable` 来彻底禁用 WLAN 功能。
### Fedora / CentOS (rpm)
#### 直接安装 rpm 包
1. 使用 [浙大源配置生成器](https://mirrors.zju.edu.cn/#generator) 生成需要的浙大源配置,并按照提示修改 `/etc/yum.repos.d` 中的文件。
2. 执行这些步骤以使用 [浙大源 EPEL](https://mirrors.zju.edu.cn/epel/) (以 CentOS 为例):
1. 运行 `yum install epel-release` 以安装 EPEL 。
2. 编辑 `/etc/yum.repos.d/epel.repo` ,将所有以 `#baseurl=` 开头的行取消注释(删除行首 `#` 符号)并注释以 `mirrorlist=` 开头的行(在行首添加 `#` 符号)
3. 继续编辑 `/etc/yum.repos.d/epel.repo` ,将所有 `https://download.fedoraproject.org/pub` 替换为 `https://mirrors.zju.edu.cn`
从 [Releases 页](https://github.com/QSCTech/zjunet/releases) 下载 rpm 包,
双击安装或运行 `sudo yum localinstall zjunet-(版本).noarch.rpm`
3. 依次输入并执行下列命令:
**注意** CentOS 7 中需要 epel 源提供 xl2tpd 。
```bash
curl https://dl.zjuqsc.com/linux/qsc.public.key | sudo tee /etc/pki/rpm-gpg/RPM-GPG-KEY-QSC-COMP66
curl https://dl.zjuqsc.com/linux/yum/qsc.repo | sudo tee /etc/yum.repos.d/qsc.repo
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-QSC-COMP66
sudo yum install zjunet
```
4. 安装结束!您可以输入 `zjunet version` 查看安装的版本,输入 `zjunet usage` 查看用法。
5. 如果你是服务器用户,建议运行 `zjunet wlan disable` 来彻底禁用 WLAN 功能。
### OpenWrt (opk)
从 [Releases 页](https://github.com/QSCTech/zjunet/releases) 下载 opk 包到路由器上,
运行 `opkg install ./zjunet_版本_all.opk`
### Other linux (源代码安装)
### 其他 Linux (源代码安装)
```bash
xl2tpd -v; curl -V; dig -v # 检查依赖命令的安装情况。这句命令将输出三个版本号。
# 在合适的目录下
git clone https://github.com/QSCTech/zjunet.git
cd zjunet
sudo ./install.sh
# 如果想要更新请在 zjunet 目录下运行 git pull 并再次 sudo ./install.sh
# 如果你是服务器用户,建议运行 `zjunet wlan disable` 来彻底禁用 WLAN 功能。
```
**注意** 运行 `./install.sh`**不会** 确认必要依赖是否已经安装。
您应当运行 `xl2tpd -v``curl -V``dig -v` 确认安装。
您应当运行 `xl2tpd -v``curl -V``dig -v` 确认安装。
## 疑难解答
### 出现了 `xl2tpd-control: command not found` 的提示但直接运行 `xl2tpd-control` 有效
出现这种情况通常是由于 `sudo``secure path` 被启用。
请编辑 `/etc/sudoers` 并在 `Defaults secure_path=xxxxxxx` 行添加 `xl2tpd-control` 所在路径(运行 `which xl2tpd-control` 查看)。编辑后的这行类似这样:
```
Defaults secure_path="/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin"
```
你可以运行 `sudo env | grep PATH` 来验证配置。显示的内容应当包括刚才添加的路径。
### 丢包
这是一个已知问题。在同时连接 VPN 和 ZJUWLAN 时,

View File

@ -65,18 +65,18 @@ connect() {
case "$1" in
-d)
d|-d|disconnect)
disconnect
;;
disconnect)
disconnect
;;
*)
""|c|-c|connect)
disconnect
sleep 3
connect
;;
*)
echo Invalid subcommand \"$1\" for \`zjunet vpn\`. Run \`zjunet usage\` for help.
;;
esac

View File

@ -24,11 +24,18 @@
BASEDIR=$(dirname $0)
DISABLE_CHECK=${BASEDIR}/.disable-wlan
USER="${BASEDIR}/user.sh"
USERNAME=$($USER get)
PASSWORD=$($USER getpwd $USERNAME)
if [[ -f "${DISABLE_CHECK}" ]]; then
echo WLAN function has been disabled.;
exit 1;
fi
logout() {
USERNAME=$1
PASSWORD=$2
@ -94,7 +101,11 @@ login() {
;;
*)
echo "Login: failed." >&2
echo "Login: ${RESPONSE}" >&2
if [[ -z "${RESPONSE}" ]]; then
echo "Login: (Empty response)" >&2
else
echo "Login: ${RESPONSE}" >&2
fi
exit 1
;;
esac
@ -102,15 +113,22 @@ login() {
case "$1" in
disconnect)
d|-d|disconnect)
logout $USERNAME $PASSWORD
;;
-d)
logout $USERNAME $PASSWORD
;;
*)
""|c|-c|connect)
login $USERNAME $PASSWORD
;;
disable)
"${BASEDIR}/sudo.sh" touch "${DISABLE_CHECK}"
exit 0
;;
*)
echo Invalid subcommand \"$1\" for \`zjunet wlan\`. Run \`zjunet usage\` for help.
;;
esac
"${BASEDIR}/sudo.sh" "${BASEDIR}/route.sh"

View File

@ -22,54 +22,61 @@ BASEDIR=$(dirname $0)
MISCELLDIR="$BASEDIR/../../share/zjunet"
case "$1" in
route)
r|route)
"${BASEDIR}/sudo.sh" "${BASEDIR}/route.sh"
;;
user)
u|user)
"${BASEDIR}/user.sh" $2
;;
all)
a|all)
"${BASEDIR}/wlan.sh" $2
"${BASEDIR}/vpn.sh" $2
;;
wlan)
w|wlan)
"${BASEDIR}/wlan.sh" $2
;;
vpn)
v|vpn)
"${BASEDIR}/vpn.sh" $2
;;
dns)
d|dns)
"${BASEDIR}/dns.sh" $2
;;
version|--version)
-v|version|--version)
version_full=`cat "${MISCELLDIR}/VERSION"`
version=$(echo $version_full | sed 's/-.*//')
echo "zjunet version: $version (${version_full})"
;;
*)
cat <<EOF
zjunet: cli tool (VPN/WLAN/DNS) for network connection in ZJU
zjunet: CLI tool (VPN/WLAN/DNS) for network connection in ZJU
Usage: zjunet [ACTION]
Actions:
user
add Add a user
list List all enabled users
edit Edit a (enabled) user
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
connect(-c) Connect VPN & ZJUWLAN, and combine them using nexthop
disconnect(-d) Disconnect VPN & ZJUWLAN
vpn
connect(-c) Connect VPN and set up ip route
disconnect(-d) Disconnect VPN and reset ip route
wlan
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
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
EOF
;;
esac