mirror of
https://github.com/QSCTech/zjunet.git
synced 2026-01-22 11:44:48 +08:00
Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff6ed1ab75 | ||
|
|
89810b80c9 | ||
|
|
7bd9e67936 | ||
|
|
cfd6c16f60 | ||
|
|
9b7f791fd4 | ||
|
|
0e5b349cfb | ||
|
|
e46b04691a | ||
| 51240ecc87 | |||
|
|
d601644df2 | ||
|
|
9b02ca93eb | ||
|
|
426663b9c1 | ||
|
|
51ae7a6ceb | ||
|
|
3316d0fa01 | ||
|
|
2bfab862d5 | ||
|
|
0b789525d1 | ||
|
|
e59b4d96db | ||
|
|
acf3e2a1e2 | ||
|
|
18f55d6120 | ||
|
|
195210365e | ||
|
|
e531ed2f97 | ||
|
|
f8ca63933e | ||
|
|
a587c43bd1 | ||
|
|
731be425a6 | ||
|
|
6c635487a2 | ||
|
|
fce9e2a69d | ||
|
|
fc48eff092 | ||
|
|
887de1b822 | ||
|
|
701a17a1e2 | ||
|
|
2fa9b0a1e8 | ||
|
|
f179d6817f | ||
|
|
d8c9413580 | ||
|
|
b446175d51 | ||
|
|
c44a4105d4 | ||
|
|
a294ecaed0 | ||
|
|
69a1633e8a | ||
|
|
17d91a4157 | ||
|
|
9c4ca315ce | ||
|
|
6747ef8c4a |
32
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
32
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a bug report to help us locate problems
|
||||||
|
title: ''
|
||||||
|
labels: bug
|
||||||
|
assignees: ''
|
||||||
|
---
|
||||||
|
|
||||||
|
## Environment
|
||||||
|
Please complete the following information:
|
||||||
|
- **OS:** [OS name and version, e.g. Ubuntu 20.10, CentOS 8]
|
||||||
|
- **zjunet:** [output of `zjunet -v`, e.g. 0.3.3-3]
|
||||||
|
- **xl2tpd:** [output of `xl2tpd -v`, e.g. 1.3.16]
|
||||||
|
- **network type:** [wired or wireless or ...]
|
||||||
|
- other softwares or the network condition that may related to this bug
|
||||||
|
|
||||||
|
## Bug description
|
||||||
|
A clear and concise description of what the bug is and how to reproduce it.
|
||||||
|
|
||||||
|
## Output
|
||||||
|
|
||||||
|
Full output of command line tools.
|
||||||
|
|
||||||
|
If applicable, add screenshots to help explain the problem.
|
||||||
|
|
||||||
|
```
|
||||||
|
[user@host ~]# zjunet XXXX
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
Add other information that may related to this bug.
|
||||||
14
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
14
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest a new idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: feature
|
||||||
|
assignees: ''
|
||||||
|
---
|
||||||
|
|
||||||
|
## Description
|
||||||
|
A brief explanation of the feature.
|
||||||
|
|
||||||
|
## Motivation
|
||||||
|
Why such feature is worthy? What use cases does it support?
|
||||||
|
|
||||||
38
.github/workflows/packaging.yml
vendored
Normal file
38
.github/workflows/packaging.yml
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# This workflow build packages for release
|
||||||
|
|
||||||
|
name: Packaging
|
||||||
|
|
||||||
|
# Controls when the action will run. Triggers the workflow when releases created or modified
|
||||||
|
on:
|
||||||
|
create:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: '^3.7' # request python 3.7+ for datetime.datetime.fromisoformat
|
||||||
|
|
||||||
|
- name: Build Packages
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
python -m pip install urllib3
|
||||||
|
cd build
|
||||||
|
./build.sh
|
||||||
|
|
||||||
|
- name: Archive Packages
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: Release Packages
|
||||||
|
path: |
|
||||||
|
build/debian/zjunet_*.deb
|
||||||
|
build/rpm/zjunet-*.rpm
|
||||||
|
build/openwrt/zjunet_*.opk
|
||||||
23
.gitlab-ci.yml
Normal file
23
.gitlab-ci.yml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
image: ubuntu:jammy
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- build
|
||||||
|
|
||||||
|
compile:
|
||||||
|
stage: build
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
|
script:
|
||||||
|
- sed -i 's|http.*.ubuntu.com|http://mirrors.zju.edu.cn|' /etc/apt/sources.list
|
||||||
|
- apt-get update && apt-get -y --no-install-recommends install ca-certificates build-essential fakeroot git dpkg-dev rpm python3 python-is-python3 python3-urllib3
|
||||||
|
- mkdir artifacts
|
||||||
|
- pushd build
|
||||||
|
- ./build.sh
|
||||||
|
- popd
|
||||||
|
- cp build/debian/*.deb artifacts/
|
||||||
|
- cp build/openwrt/*.opk artifacts/
|
||||||
|
- cp build/rpm/*.rpm artifacts/
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- /artifacts
|
||||||
|
|
||||||
27
README.md
27
README.md
@ -22,8 +22,6 @@ Command Line Scripts for ZJU (VPN / WLAN / DNS)
|
|||||||
|
|
||||||
- xl2tpd
|
- xl2tpd
|
||||||
|
|
||||||
- curl
|
|
||||||
|
|
||||||
- `dig` (Different package on different platform)
|
- `dig` (Different package on different platform)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@ -32,12 +30,12 @@ If you meet any problem during or after the installation, check Troubleshooting
|
|||||||
|
|
||||||
### Debian / Ubuntu (deb)
|
### Debian / Ubuntu (deb)
|
||||||
|
|
||||||
1. Configure ZJU mirrors using [浙大源配置生成器](https://mirrors.zju.edu.cn/#generator).
|
1. Configure ZJU mirrors from manual. [Ubuntu](https://mirror.zju.edu.cn/docs/ubuntu/)/[Debian](https://mirror.zju.edu.cn/docs/debian/)
|
||||||
2. Run these command.
|
2. Run these command.
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
curl https://dl.zjuqsc.com/linux/qsc.public.key | sudo apt-key add -
|
curl https://mirrors.zju.edu.cn/openzjunet/zjumirrors.pgp | sudo tee /etc/apt/trusted.gpg.d/zjumirrors.asc
|
||||||
curl https://dl.zjuqsc.com/linux/debian/qsc.list | sudo tee /etc/apt/sources.list.d/qsc.list
|
curl https://mirrors.zju.edu.cn/openzjunet/zjunet.list | sudo tee /etc/apt/sources.list.d/zjunet.list
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install zjunet
|
sudo apt-get install zjunet
|
||||||
```
|
```
|
||||||
@ -47,7 +45,7 @@ sudo apt-get install zjunet
|
|||||||
|
|
||||||
### Fedora / CentOS (rpm)
|
### Fedora / CentOS (rpm)
|
||||||
|
|
||||||
1. Configure ZJU mirrors using [浙大源配置生成器](https://mirrors.zju.edu.cn/#generator).
|
1. Configure ZJU mirrors from manual. [Fedora](https://mirror.zju.edu.cn/docs/fedora/)/[CentOS](https://mirror.zju.edu.cn/docs/centos/)
|
||||||
2. Configure [EPEL of ZJU mirrors](https://mirrors.zju.edu.cn/epel/) (Taking CentOS installation as an example)
|
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.
|
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)
|
2. Edit `/etc/yum.repos.d/epel.repo` , uncomment lines begin with `#baseurl=` (Remove leading `#` sign) and comment lines begin with `mirrorlist=` (Prepend `#` sign)
|
||||||
@ -56,9 +54,9 @@ sudo apt-get install zjunet
|
|||||||
3. Run these command.
|
3. Run these command.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl https://dl.zjuqsc.com/linux/qsc.public.key | sudo tee /etc/pki/rpm-gpg/RPM-GPG-KEY-QSC-COMP66
|
curl https://mirrors.zju.edu.cn/openzjunet/zjumirrors.pgp | sudo tee /etc/pki/rpm-gpg/RPM-GPG-KEY-ZJUMIRRORS
|
||||||
curl https://dl.zjuqsc.com/linux/yum/qsc.repo | sudo tee /etc/yum.repos.d/qsc.repo
|
curl https://mirrors.zju.edu.cn/openzjunet/zjunet.repo | sudo tee /etc/yum.repos.d/zjunet.repo
|
||||||
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-QSC-COMP66
|
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-ZJUMIRRORS
|
||||||
sudo yum install zjunet
|
sudo yum install zjunet
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -70,10 +68,17 @@ sudo yum install zjunet
|
|||||||
Download .opk package from [Release Page](https://github.com/QSCTech/zjunet/releases) (onto your router),
|
Download .opk package from [Release Page](https://github.com/QSCTech/zjunet/releases) (onto your router),
|
||||||
Run `opkg install ./zjunet_<version>_all.opk`.
|
Run `opkg install ./zjunet_<version>_all.opk`.
|
||||||
|
|
||||||
|
### Arch Linux (AUR)
|
||||||
|
|
||||||
|
Simply run `yay zjunet` to build the package from AUR and install it.
|
||||||
|
|
||||||
|
Keep in mind that a fresh install without internet connection is almost impossible.
|
||||||
|
Please complete installation before connecting to the intranet.
|
||||||
|
|
||||||
### Other Linux (Build from source code)
|
### Other Linux (Build from source code)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
xl2tpd -v; curl -V; dig -v # Check installation of dependencies. There should be 3 version numbers.
|
xl2tpd -v; dig -v # Check installation of dependencies. There should be 3 version numbers.
|
||||||
# Under proper directory
|
# Under proper directory
|
||||||
git clone https://github.com/QSCTech/zjunet.git
|
git clone https://github.com/QSCTech/zjunet.git
|
||||||
cd zjunet
|
cd zjunet
|
||||||
@ -83,7 +88,7 @@ sudo ./install.sh
|
|||||||
```
|
```
|
||||||
|
|
||||||
**ATTENTION** Requirement check will **NOT** be done running `./install.sh`.
|
**ATTENTION** Requirement check will **NOT** be done running `./install.sh`.
|
||||||
Please run `xl2tpd -v`, `curl -V` and `dig -v` to verify the installation.
|
Please run `xl2tpd -v` and `dig -v` to verify the installation.
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
|
|||||||
27
README.zh.md
27
README.zh.md
@ -20,8 +20,6 @@
|
|||||||
|
|
||||||
- xl2tpd
|
- xl2tpd
|
||||||
|
|
||||||
- curl
|
|
||||||
|
|
||||||
- `dig` (在不同平台的包不同)
|
- `dig` (在不同平台的包不同)
|
||||||
|
|
||||||
## 安装
|
## 安装
|
||||||
@ -35,12 +33,12 @@
|
|||||||
|
|
||||||
### Debian / Ubuntu (deb)
|
### Debian / Ubuntu (deb)
|
||||||
|
|
||||||
1. 使用 [浙大源配置生成器](https://mirrors.zju.edu.cn/#generator) 生成需要的浙大源配置,并按照提示将 `/etc/apt/sources.list` 替换为显示的内容。
|
1. 使用浙大源配置内网软件包镜像。 [Ubuntu](https://mirror.zju.edu.cn/docs/ubuntu/)/[Debian](https://mirror.zju.edu.cn/docs/debian/).
|
||||||
2. 依次输入并执行下列命令:
|
2. 依次输入并执行下列命令:
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
curl https://dl.zjuqsc.com/linux/qsc.public.key | sudo apt-key add -
|
curl https://mirrors.zju.edu.cn/openzjunet/zjumirrors.pgp | sudo tee /etc/apt/trusted.gpg.d/zjumirrors.asc
|
||||||
curl https://dl.zjuqsc.com/linux/debian/qsc.list | sudo tee /etc/apt/sources.list.d/qsc.list
|
curl https://mirrors.zju.edu.cn/openzjunet/zjunet.list | sudo tee /etc/apt/sources.list.d/zjunet.list
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install zjunet
|
sudo apt-get install zjunet
|
||||||
```
|
```
|
||||||
@ -50,7 +48,7 @@ sudo apt-get install zjunet
|
|||||||
|
|
||||||
### Fedora / CentOS (rpm)
|
### Fedora / CentOS (rpm)
|
||||||
|
|
||||||
1. 使用 [浙大源配置生成器](https://mirrors.zju.edu.cn/#generator) 生成需要的浙大源配置,并按照提示修改 `/etc/yum.repos.d` 中的文件。
|
1. 使用浙大源配置内网软件包镜像。 [Fedora](https://mirror.zju.edu.cn/docs/fedora/)/[CentOS](https://mirror.zju.edu.cn/docs/centos/)
|
||||||
2. 执行这些步骤以使用 [浙大源 EPEL](https://mirrors.zju.edu.cn/epel/) (以 CentOS 为例):
|
2. 执行这些步骤以使用 [浙大源 EPEL](https://mirrors.zju.edu.cn/epel/) (以 CentOS 为例):
|
||||||
1. 运行 `yum install epel-release` 以安装 EPEL 。
|
1. 运行 `yum install epel-release` 以安装 EPEL 。
|
||||||
2. 编辑 `/etc/yum.repos.d/epel.repo` ,将所有以 `#baseurl=` 开头的行取消注释(删除行首 `#` 符号)并注释以 `mirrorlist=` 开头的行(在行首添加 `#` 符号)
|
2. 编辑 `/etc/yum.repos.d/epel.repo` ,将所有以 `#baseurl=` 开头的行取消注释(删除行首 `#` 符号)并注释以 `mirrorlist=` 开头的行(在行首添加 `#` 符号)
|
||||||
@ -59,9 +57,9 @@ sudo apt-get install zjunet
|
|||||||
3. 依次输入并执行下列命令:
|
3. 依次输入并执行下列命令:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl https://dl.zjuqsc.com/linux/qsc.public.key | sudo tee /etc/pki/rpm-gpg/RPM-GPG-KEY-QSC-COMP66
|
curl https://mirrors.zju.edu.cn/openzjunet/zjumirrors.pgp | sudo tee /etc/pki/rpm-gpg/RPM-GPG-KEY-ZJUMIRRORS
|
||||||
curl https://dl.zjuqsc.com/linux/yum/qsc.repo | sudo tee /etc/yum.repos.d/qsc.repo
|
curl https://mirrors.zju.edu.cn/openzjunet/zjunet.repo | sudo tee /etc/yum.repos.d/zjunet.repo
|
||||||
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-QSC-COMP66
|
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-ZJUMIRRORS
|
||||||
sudo yum install zjunet
|
sudo yum install zjunet
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -73,10 +71,17 @@ sudo yum install zjunet
|
|||||||
从 [Releases 页](https://github.com/QSCTech/zjunet/releases) 下载 opk 包到路由器上,
|
从 [Releases 页](https://github.com/QSCTech/zjunet/releases) 下载 opk 包到路由器上,
|
||||||
运行 `opkg install ./zjunet_(版本)_all.opk` 。
|
运行 `opkg install ./zjunet_(版本)_all.opk` 。
|
||||||
|
|
||||||
|
### Arch Linux (AUR)
|
||||||
|
|
||||||
|
直接运行 `yay zjunet` 即可下载并安装。
|
||||||
|
|
||||||
|
请记住,在没有互联网连接的环境中是几乎不可能安装好的。
|
||||||
|
请在连接到校内网前,在有互联网连接的环境中先完成安装。
|
||||||
|
|
||||||
### 其他 Linux (源代码安装)
|
### 其他 Linux (源代码安装)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
xl2tpd -v; curl -V; dig -v # 检查依赖命令的安装情况。这句命令将输出三个版本号。
|
xl2tpd -v; dig -v # 检查依赖命令的安装情况。这句命令将输出三个版本号。
|
||||||
# 在合适的目录下
|
# 在合适的目录下
|
||||||
git clone https://github.com/QSCTech/zjunet.git
|
git clone https://github.com/QSCTech/zjunet.git
|
||||||
cd zjunet
|
cd zjunet
|
||||||
@ -86,7 +91,7 @@ sudo ./install.sh
|
|||||||
```
|
```
|
||||||
|
|
||||||
**注意** 运行 `./install.sh` 时 **不会** 确认必要依赖是否已经安装。
|
**注意** 运行 `./install.sh` 时 **不会** 确认必要依赖是否已经安装。
|
||||||
您应当先运行 `xl2tpd -v` 、 `curl -V` 和 `dig -v` 确认安装。
|
您应当先运行 `xl2tpd -v` 、 `dig -v` 确认安装。
|
||||||
|
|
||||||
## 疑难解答
|
## 疑难解答
|
||||||
|
|
||||||
|
|||||||
42
build/build-pkgbuild.sh
Executable file
42
build/build-pkgbuild.sh
Executable file
@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
PKGNAME=zjunet
|
||||||
|
PKGVER=$(cat $(dirname $0)/../VERSION)
|
||||||
|
PKGVER_NOREL=${PKGVER%%-*}
|
||||||
|
PKGREL=${PKGVER:$((${#PKGVER_NOREL}+1))}
|
||||||
|
if [[ -z $PKGREL ]]; then
|
||||||
|
PKGREL=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -xe
|
||||||
|
|
||||||
|
wget https://github.com/QSCTech/$PKGNAME/archive/v$PKGVER.tar.gz -O $PKGNAME-$PKGVER.tar.gz
|
||||||
|
|
||||||
|
FILE_MD5=$(md5sum $PKGNAME-$PKGVER.tar.gz | cut -f1 -d' ')
|
||||||
|
FILE_SHA1=$(sha1sum $PKGNAME-$PKGVER.tar.gz | cut -f1 -d' ')
|
||||||
|
FILE_SHA256=$(sha256sum $PKGNAME-$PKGVER.tar.gz | cut -f1 -d' ')
|
||||||
|
|
||||||
|
cat > PKGBUILD <<EOF
|
||||||
|
# Maintainer: Azuk 443 <me@azuk.top>
|
||||||
|
|
||||||
|
pkgname=$PKGNAME
|
||||||
|
pkgver=$PKGVER_NOREL
|
||||||
|
pkgrel=$PKGREL
|
||||||
|
pkgdesc="Command Line Scripts for ZJU"
|
||||||
|
url="https://github.com/QSCTech/$PKGNAME"
|
||||||
|
arch=('any')
|
||||||
|
license=('GPL')
|
||||||
|
depends=('xl2tpd>=1.3.7' 'dnsutils')
|
||||||
|
source=("$PKGNAME-$PKGVER.tar.gz::https://github.com/QSCTech/$PKGNAME/archive/v$PKGVER.tar.gz")
|
||||||
|
md5sums=('$FILE_MD5')
|
||||||
|
sha1sums=('$FILE_SHA1')
|
||||||
|
sha256sums=('$FILE_SHA256')
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cd "\$srcdir/$PKGNAME-$PKGVER"
|
||||||
|
DESTDIR=\$pkgdir PREFIX=/usr ./install.sh
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
makepkg $*
|
||||||
|
makepkg --printsrcinfo > .SRCINFO
|
||||||
@ -6,17 +6,46 @@ fail() {
|
|||||||
echo -e "\033[31mERROR: Failed to build $1\033[0m" 1>&2
|
echo -e "\033[31mERROR: Failed to build $1\033[0m" 1>&2
|
||||||
}
|
}
|
||||||
|
|
||||||
pushd rpm > /dev/null
|
if [[ $# -gt 0 ]]; then
|
||||||
./build.sh $VERSION || fail 'RPM package'
|
for arg in $*; do
|
||||||
popd > /dev/null
|
case $arg in
|
||||||
|
rpm)
|
||||||
|
USE_RPM=1
|
||||||
|
;;
|
||||||
|
debian)
|
||||||
|
USE_DEB=1
|
||||||
|
;;
|
||||||
|
openwrt)
|
||||||
|
USE_OPK=1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Invalid package $arg"
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
else
|
||||||
|
USE_RPM=1
|
||||||
|
USE_DEB=1
|
||||||
|
USE_OPK=1
|
||||||
|
fi
|
||||||
|
|
||||||
pushd debian > /dev/null
|
if [[ ! -z $USE_RPM ]]; then
|
||||||
./build.sh $VERSION || fail 'Debian package'
|
pushd rpm > /dev/null
|
||||||
popd > /dev/null
|
./build.sh $VERSION || fail 'RPM package'
|
||||||
|
popd > /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
pushd openwrt > /dev/null
|
if [[ ! -z $USE_DEB ]]; then
|
||||||
./build.sh $VERSION || fail 'OpenWrt package'
|
pushd debian > /dev/null
|
||||||
popd > /dev/null
|
./build.sh $VERSION || fail 'Debian package'
|
||||||
|
popd > /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -z $USE_OPK ]]; then
|
||||||
|
pushd openwrt > /dev/null
|
||||||
|
./build.sh $VERSION || fail 'OpenWrt package'
|
||||||
|
popd > /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
echo -ne "\033[0;32m"
|
echo -ne "\033[0;32m"
|
||||||
find . -regextype posix-egrep -regex ".*\.(opk|deb|rpm)$"
|
find . -regextype posix-egrep -regex ".*\.(opk|deb|rpm)$"
|
||||||
|
|||||||
127
build/changelog.py
Executable file
127
build/changelog.py
Executable file
@ -0,0 +1,127 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
import base64
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
if sys.version_info.major < 3:
|
||||||
|
reload(sys)
|
||||||
|
sys.setdefaultencoding('utf8')
|
||||||
|
|
||||||
|
try:
|
||||||
|
import urllib3
|
||||||
|
http = urllib3.PoolManager()
|
||||||
|
def makereq(url, headers):
|
||||||
|
return http.request('GET', url, headers=headers)
|
||||||
|
except ImportError:
|
||||||
|
import urllib2 as request
|
||||||
|
class MyResponse:
|
||||||
|
def __init__(self, status, data):
|
||||||
|
self.status = status
|
||||||
|
self.data = data
|
||||||
|
def makereq(url, headers):
|
||||||
|
f = request.urlopen(request.Request(url, headers=headers))
|
||||||
|
return MyResponse(f.getcode(), f.read().decode('utf-8'))
|
||||||
|
|
||||||
|
|
||||||
|
if 'fromisoformat' in dir(datetime.datetime):
|
||||||
|
def get_time(s):
|
||||||
|
return datetime.datetime.fromisoformat(s.replace('Z', '+00:00'))
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
from dateutil.parser import parser
|
||||||
|
def get_time(s):
|
||||||
|
return parser().parse(s)
|
||||||
|
except ImportError:
|
||||||
|
def get_time(s):
|
||||||
|
return datetime.datetime.strptime(s, "%Y-%m-%dT%H:%M:%SZ")
|
||||||
|
|
||||||
|
|
||||||
|
GITHUB_AUTH = None
|
||||||
|
tok = os.getenv('GITHUB_TOKEN')
|
||||||
|
usn = os.getenv('GITHUB_USERNAME')
|
||||||
|
psw = os.getenv('GITHUB_PASSWORD')
|
||||||
|
if tok is not None:
|
||||||
|
GITHUB_AUTH = 'token {}'.format(tok)
|
||||||
|
elif usn is not None and psw is not None:
|
||||||
|
GITHUB_AUTH = 'Basic {}'.format(base64.b64encode('{}:{}'.format(usn, psw).encode('utf-8')).decode('utf-8'))
|
||||||
|
|
||||||
|
def get(url):
|
||||||
|
headers = {
|
||||||
|
'Accept': 'application/vnd.github.v3+json',
|
||||||
|
'User-Agent': 'zjunet-build-agent/0.1',
|
||||||
|
}
|
||||||
|
if GITHUB_AUTH is not None:
|
||||||
|
headers['Authorization'] = GITHUB_AUTH
|
||||||
|
r = makereq(url, headers=headers)
|
||||||
|
assert r.status // 100 == 2, 'HTTP Status {} != 2xx while requesting {}'.format(r.status, url)
|
||||||
|
if r.status != 200:
|
||||||
|
print('WARNING: HTTP {} while requesting {}'.format(r.status, url))
|
||||||
|
return r.data
|
||||||
|
|
||||||
|
def api_get(url):
|
||||||
|
return json.loads(get('https://api.github.com/' + url))
|
||||||
|
|
||||||
|
author_cache = {}
|
||||||
|
def get_author(name):
|
||||||
|
if name in author_cache:
|
||||||
|
return author_cache[name]
|
||||||
|
print('Reading data for {}'.format(name), end=' : ', file=sys.stderr)
|
||||||
|
data = api_get('users/{}'.format(name))
|
||||||
|
data = {
|
||||||
|
'name': data['name'],
|
||||||
|
'email': data['email'],
|
||||||
|
}
|
||||||
|
author_cache[name] = data
|
||||||
|
print('{} <{}>'.format(data['name'], data['email']), file=sys.stderr)
|
||||||
|
return data
|
||||||
|
|
||||||
|
def get_changelog(owner, name):
|
||||||
|
print('Reading releases of {1} in {0}'.format(owner, name), file=sys.stderr)
|
||||||
|
releases = api_get('repos/{}/{}/releases'.format(owner, name))
|
||||||
|
releases = filter(lambda v: not v['draft'] and not v['prerelease'], releases)
|
||||||
|
|
||||||
|
data = []
|
||||||
|
for rel in releases:
|
||||||
|
name = rel['name'] or rel['tag_name']
|
||||||
|
item = {
|
||||||
|
'time': get_time(rel['published_at']),
|
||||||
|
'name': name,
|
||||||
|
'version': name[name.rfind('v') + 1:].split(','),
|
||||||
|
'author': get_author(rel['author']['login']),
|
||||||
|
'changes': None,
|
||||||
|
}
|
||||||
|
tbody = rel['body'].strip()
|
||||||
|
if tbody != '':
|
||||||
|
if tbody[0] != '-' and '\n' not in tbody:
|
||||||
|
item['changes'] = '- ' + tbody
|
||||||
|
else:
|
||||||
|
item['changes'] = tbody
|
||||||
|
|
||||||
|
data.append(item)
|
||||||
|
return ChangeLog(data)
|
||||||
|
|
||||||
|
class ChangeLog:
|
||||||
|
def __init__(self, data):
|
||||||
|
self.raw = data
|
||||||
|
def rpm(self):
|
||||||
|
rel = '%changelog\n'
|
||||||
|
for item in self.raw:
|
||||||
|
rel += '* {} {} <{}> - {}\n'.format(item['time'].strftime('%a %b %d %Y'), item['author']['name'], item['author']['email'], '.'.join(item['version']))
|
||||||
|
if item['changes'] is not None:
|
||||||
|
rel += item['changes'] + '\n'
|
||||||
|
return rel
|
||||||
|
|
||||||
|
available_formats = list(filter(lambda v: v[0] != '_', dir(ChangeLog)))
|
||||||
|
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
print('Usage: {} <format>\nAvailable formats: {}'.format(sys.argv[0], ','.join(available_formats)))
|
||||||
|
else:
|
||||||
|
changelog = get_changelog('QSCTech', 'zjunet')
|
||||||
|
if hasattr(changelog, sys.argv[1]):
|
||||||
|
print(getattr(changelog, sys.argv[1])())
|
||||||
|
else:
|
||||||
|
print('Invalid format {}\nAvailable formats: {}'.format(','.join(available_formats)))
|
||||||
@ -36,15 +36,15 @@ Version: $VERSION
|
|||||||
Section: net
|
Section: net
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Depends: xl2tpd (>= 1.3.1), curl, dnsutils
|
Depends: xl2tpd (>= 1.3.7), dnsutils
|
||||||
Maintainer: Tespent <me@tespent.cn>
|
Maintainer: Azuk 443 <me@azuk.top>
|
||||||
Description: Command Line Scripts for ZJU
|
Description: Command Line Scripts for ZJU Campus Network
|
||||||
This script provides a VPN / WLAN / NEXTHOP for ZJUer.
|
This script provides a VPN / WLAN / NEXTHOP for ZJUer.
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# dpkg-deb
|
# dpkg-deb
|
||||||
find ./debian -type d | xargs chmod 755
|
find ./debian -type d | xargs chmod 755
|
||||||
fakeroot dpkg-deb --build debian
|
fakeroot dpkg-deb -Zxz --build debian
|
||||||
mv debian.deb zjunet_${VERSION}_all.deb
|
mv debian.deb zjunet_${VERSION}_all.deb
|
||||||
|
|
||||||
# remove debian/
|
# remove debian/
|
||||||
|
|||||||
@ -26,9 +26,9 @@ Version: $VERSION
|
|||||||
Section: net
|
Section: net
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Depends: xl2tpd (>= 1.3.1), curl, bind-dig
|
Depends: xl2tpd (>= 1.3.7), bind-dig
|
||||||
Maintainer: Tespent <me@tespent.cn>
|
Maintainer: Azuk 443 <me@azuk.top>
|
||||||
Description: Command Line Scripts for ZJU
|
Description: Command Line Scripts for ZJU Campus Network
|
||||||
This script provides a VPN / WLAN / NEXTHOP for ZJUer.
|
This script provides a VPN / WLAN / NEXTHOP for ZJUer.
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
VERSION=$1
|
VERSION=$1
|
||||||
REALVERSION=`echo "$VERSION" | cut -d'-' -f1`
|
REALVERSION=`echo "$VERSION" | cut -d'-' -f1`
|
||||||
@ -12,8 +12,8 @@ echo "License: GPL" >> zjunet.spec
|
|||||||
echo "Group: Applications/Internet" >> zjunet.spec
|
echo "Group: Applications/Internet" >> zjunet.spec
|
||||||
echo "URL: https://github.com/QSCTech/zjunet/" >> zjunet.spec
|
echo "URL: https://github.com/QSCTech/zjunet/" >> zjunet.spec
|
||||||
echo "Vendor: Qiu Shi Chao Website of Zhejiang University" >> zjunet.spec
|
echo "Vendor: Qiu Shi Chao Website of Zhejiang University" >> zjunet.spec
|
||||||
echo "Packager: Tespent <me@tespent.cn>" >> zjunet.spec
|
echo "Packager: Azuk 443 <me@azuk.top>" >> zjunet.spec
|
||||||
echo "Requires: xl2tpd >= 1.3.1, curl, bind-utils" >> zjunet.spec
|
echo "Requires: xl2tpd >= 1.3.7, bind-utils" >> zjunet.spec
|
||||||
echo "BuildRoot: %{_builddir}/%{name}-root" >> zjunet.spec
|
echo "BuildRoot: %{_builddir}/%{name}-root" >> zjunet.spec
|
||||||
echo "Source: %{name}-%{version}.tar.gz" >> zjunet.spec
|
echo "Source: %{name}-%{version}.tar.gz" >> zjunet.spec
|
||||||
echo "BuildArch: noarch" >> zjunet.spec
|
echo "BuildArch: noarch" >> zjunet.spec
|
||||||
@ -41,14 +41,10 @@ for f in *.sh; do
|
|||||||
done
|
done
|
||||||
cd ..
|
cd ..
|
||||||
echo 'install -m 644 VERSION $RPM_BUILD_ROOT/usr/share/zjunet/VERSION' >> zjunet.spec
|
echo 'install -m 644 VERSION $RPM_BUILD_ROOT/usr/share/zjunet/VERSION' >> zjunet.spec
|
||||||
echo 'install -m 644 qsc.public.key $RPM_BUILD_ROOT/usr/share/zjunet/qsc.public.key' >> zjunet.spec
|
|
||||||
echo 'install -m 644 qsc.repo $RPM_BUILD_ROOT/usr/share/zjunet/qsc.repo' >> zjunet.spec
|
|
||||||
echo "" >> zjunet.spec
|
echo "" >> zjunet.spec
|
||||||
echo "%files" >> zjunet.spec
|
echo "%files" >> zjunet.spec
|
||||||
echo "%defattr(-,root,root)" >> zjunet.spec
|
echo "%defattr(-,root,root)" >> zjunet.spec
|
||||||
echo "/usr/bin/zjunet" >> zjunet.spec
|
echo "/usr/bin/zjunet" >> zjunet.spec
|
||||||
echo "/usr/share/zjunet/qsc.public.key" >> zjunet.spec
|
|
||||||
echo "/usr/share/zjunet/qsc.repo" >> zjunet.spec
|
|
||||||
echo "/usr/share/zjunet/zjunet-postinst" >> zjunet.spec
|
echo "/usr/share/zjunet/zjunet-postinst" >> zjunet.spec
|
||||||
echo "/usr/share/zjunet/VERSION" >> zjunet.spec
|
echo "/usr/share/zjunet/VERSION" >> zjunet.spec
|
||||||
cd lib
|
cd lib
|
||||||
@ -63,23 +59,5 @@ echo "" >> zjunet.spec
|
|||||||
echo "%post" >> zjunet.spec
|
echo "%post" >> zjunet.spec
|
||||||
echo "/usr/share/zjunet/zjunet-postinst || true" >> zjunet.spec
|
echo "/usr/share/zjunet/zjunet-postinst || true" >> zjunet.spec
|
||||||
echo "" >> zjunet.spec
|
echo "" >> zjunet.spec
|
||||||
echo "%changelog" >> zjunet.spec
|
|
||||||
echo "* Sun Feb 08 2015 Senorsen <sen@senorsen.com> - 0.2.4" >> zjunet.spec
|
|
||||||
echo "- Genrate debian and opkg packages using fakeroot (in case of wrong uid)" >> zjunet.spec
|
|
||||||
echo "- Replace test IP with a more stable one" >> zjunet.spec
|
|
||||||
echo "* Sun Nov 23 2014 Zeno Zeng <zenoofzeng@gmail.com> - 0.2.3" >> zjunet.spec
|
|
||||||
echo "- build.sh & zjunet.sh now share lib/version" >> zjunet.spec
|
|
||||||
echo "- fork when calling xl2tpd-control" >> zjunet.spec
|
|
||||||
echo "* Sat Nov 22 2014 Senorsen <sen@senorsen.com> - 0.2.2" >> zjunet.spec
|
|
||||||
echo "- P-t-P server address issues" >> zjunet.spec
|
|
||||||
echo "- comment typo fixed" >> zjunet.spec
|
|
||||||
echo "* Wed Nov 12 2014 Zeno Zeng <zenoofzeng@gmail.com> - 0.2.1" >> zjunet.spec
|
|
||||||
echo "- xqyww123 fixed the compatibility with systemd" >> zjunet.spec
|
|
||||||
echo "- chaosink fixed the string escape problem in user.sh" >> zjunet.spec
|
|
||||||
echo "* Wed Oct 15 2014 Zeno Zeng <zenoofzeng@gmail.com> - 0.2.0" >> zjunet.spec
|
|
||||||
echo "- Use xl2tpd.conf, abandon \$HOME/.zjunet/" >> zjunet.spec
|
|
||||||
echo "- Setup route after connect / disconnect wlan" >> zjunet.spec
|
|
||||||
echo "* Mon Oct 13 2014 Zeno Zeng <zenoofzeng@gmail.com> - 0.1.2" >> zjunet.spec
|
|
||||||
echo "* Thu Oct 02 2014 Zeno Zeng <zenoofzeng@gmail.com> - 0.1.0" >> zjunet.spec
|
|
||||||
echo "- Initial version of the package" >> zjunet.spec
|
|
||||||
|
|
||||||
|
../../changelog.py rpm >> zjunet.spec
|
||||||
|
|||||||
20
install.sh
20
install.sh
@ -7,17 +7,19 @@ if [ -z "$PREFIX" ]; then
|
|||||||
PREFIX=/usr/local
|
PREFIX=/usr/local
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p $PREFIX/lib/zjunet
|
mkdir -p $DESTDIR$PREFIX/lib/zjunet
|
||||||
cp -rf $BASEDIR/* $PREFIX/lib/zjunet
|
cp -rf $BASEDIR/* $DESTDIR$PREFIX/lib/zjunet
|
||||||
mkdir -p $PREFIX/bin
|
mkdir -p $DESTDIR$PREFIX/bin
|
||||||
mkdir -p $PREFIX/share/zjunet
|
mkdir -p $DESTDIR$PREFIX/share/zjunet
|
||||||
ln -fs ../../share/zjunet/VERSION $PREFIX/lib/zjunet/VERSION
|
ln -fs ../../share/zjunet/VERSION $DESTDIR$PREFIX/lib/zjunet/VERSION
|
||||||
cp -f VERSION $PREFIX/share/zjunet
|
cp -f VERSION $DESTDIR$PREFIX/share/zjunet
|
||||||
cat > $PREFIX/bin/zjunet << EOF
|
cat > $DESTDIR$PREFIX/bin/zjunet << EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
$PREFIX/lib/zjunet/zjunet.sh "\$@"
|
$PREFIX/lib/zjunet/zjunet.sh "\$@"
|
||||||
EOF
|
EOF
|
||||||
chmod +x $PREFIX/bin/zjunet
|
chmod +x $DESTDIR$PREFIX/bin/zjunet
|
||||||
echo "[INFO] Done."
|
echo "[INFO] Done."
|
||||||
echo
|
echo
|
||||||
zjunet usage
|
if [[ -z $DESTDIR ]]; then
|
||||||
|
zjunet usage
|
||||||
|
fi
|
||||||
|
|||||||
16
lib/route.sh
16
lib/route.sh
@ -49,6 +49,7 @@ if [ "${devs_count}" -eq "0" ]; then
|
|||||||
ip_route_del 210.32.160.0/21
|
ip_route_del 210.32.160.0/21
|
||||||
ip_route_del 210.32.168.0/22
|
ip_route_del 210.32.168.0/22
|
||||||
ip_route_del 210.32.172.0/23
|
ip_route_del 210.32.172.0/23
|
||||||
|
ip_route_del 210.32.174.0/24
|
||||||
ip_route_del 210.32.176.0/20
|
ip_route_del 210.32.176.0/20
|
||||||
ip_route_del 222.205.0.0/17
|
ip_route_del 222.205.0.0/17
|
||||||
ip_route_del 10.5.1.0/24
|
ip_route_del 10.5.1.0/24
|
||||||
@ -87,6 +88,7 @@ case "$gateway" in
|
|||||||
ip route replace 210.32.160.0/21 via $gateway
|
ip route replace 210.32.160.0/21 via $gateway
|
||||||
ip route replace 210.32.168.0/22 via $gateway
|
ip route replace 210.32.168.0/22 via $gateway
|
||||||
ip route replace 210.32.172.0/23 via $gateway
|
ip route replace 210.32.172.0/23 via $gateway
|
||||||
|
ip route replace 210.32.174.0/24 via $gateway
|
||||||
ip route replace 210.32.176.0/20 via $gateway
|
ip route replace 210.32.176.0/20 via $gateway
|
||||||
ip route replace 222.205.0.0/17 via $gateway
|
ip route replace 222.205.0.0/17 via $gateway
|
||||||
;;
|
;;
|
||||||
@ -101,20 +103,6 @@ for dev in $devs; do
|
|||||||
cmd="${cmd} nexthop dev ${dev}"
|
cmd="${cmd} nexthop dev ${dev}"
|
||||||
done
|
done
|
||||||
|
|
||||||
case "$gateway" in
|
|
||||||
10.189.*)
|
|
||||||
# WLAN
|
|
||||||
zjuwlan_test_ip=10.202.68.46
|
|
||||||
ip route replace $zjuwlan_test_ip via ${gateway}
|
|
||||||
zjuwlan_status=`curl -s $zjuwlan_test_ip | grep net.zju.edu.cn | wc -l`
|
|
||||||
if [ $zjuwlan_status -eq 0 ]
|
|
||||||
then
|
|
||||||
cmd="${cmd} nexthop via ${gateway}"
|
|
||||||
fi
|
|
||||||
ip route del $zjuwlan_test_ip || true
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
$cmd
|
$cmd
|
||||||
|
|
||||||
ip route
|
ip route
|
||||||
|
|||||||
116
lib/wlan.sh
116
lib/wlan.sh
@ -2,11 +2,10 @@
|
|||||||
|
|
||||||
# wlan.sh -- login/logout for ZJUWLAN
|
# wlan.sh -- login/logout for ZJUWLAN
|
||||||
#
|
#
|
||||||
# Requirements: curl
|
|
||||||
#
|
|
||||||
# Copyright (C) 2014 Zhang Hai <Dreaming.in.Code.ZH@Gmail.com>
|
# Copyright (C) 2014 Zhang Hai <Dreaming.in.Code.ZH@Gmail.com>
|
||||||
# Copyright (C) 2014 Zeno Zeng <zenoofzeng@gmail.com>
|
# Copyright (C) 2014 Zeno Zeng <zenoofzeng@gmail.com>
|
||||||
# Copyright (C) 2017 Wu Fan <wfwf1997@gmail.com>
|
# Copyright (C) 2017 Wu Fan <wfwf1997@gmail.com>
|
||||||
|
# Copyright (C) 2023 Azuk 443 <azukmm@gmail.com>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -22,114 +21,5 @@
|
|||||||
# along with this program. If not, see
|
# along with this program. If not, see
|
||||||
# <http://www.gnu.org/licenses/>.
|
# <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
BASEDIR=$(dirname $0)
|
echo "zjunet WLAN function is deprecated."
|
||||||
|
exit 1
|
||||||
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
|
|
||||||
|
|
||||||
echo "Logout: ${USERNAME}"
|
|
||||||
RESPONSE=$(curl "https://net.zju.edu.cn/include/auth_action.php" -H "Content-Type: application/x-www-form-urlencoded" -d "action=logout&username=${USERNAME}&password=${PASSWORD}&ajax=1" -s)
|
|
||||||
|
|
||||||
if [[ $? -eq 60 ]]; then
|
|
||||||
CHOOSE=''
|
|
||||||
read -p "There's an issue with ZJUNET's CA certificates, do you want to do it anyway? [yes/NO] " CHOOSE
|
|
||||||
if [[ $CHOOSE == "YES" ]] || [[ $CHOOSE == "yes" ]]; then
|
|
||||||
RESPONSE=$(curl "https://net.zju.edu.cn/include/auth_action.php" -H "Content-Type: application/x-www-form-urlencoded" -d "action=logout&username=${USERNAME}&password=${PASSWORD}&ajax=1" -s -k)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "${RESPONSE}" in
|
|
||||||
*ok*)
|
|
||||||
echo "Logout: success."
|
|
||||||
;;
|
|
||||||
*已断开*)
|
|
||||||
echo "Logout: success."
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Logout: unsuccess."
|
|
||||||
echo "${RESPONSE}"
|
|
||||||
exit 1;
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
login() {
|
|
||||||
USERNAME=$1
|
|
||||||
PASSWORD=$2
|
|
||||||
|
|
||||||
STATUS=$(curl http://g.cn/generate_204 -I -s | grep HTTP | awk {'print $2'})
|
|
||||||
if [[ STATUS -eq 204 ]]; then
|
|
||||||
echo "You have already logged in."
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Login: ${USERNAME}"
|
|
||||||
RESPONSE=$(curl "https://net.zju.edu.cn/include/auth_action.php" -H "Content-Type: application/x-www-form-urlencoded" -d "action=login&username=${USERNAME}&password=${PASSWORD}&ac_id=3&user_ip=&nas_ip=&user_mac=&save_me=1&ajax=1" -s)
|
|
||||||
|
|
||||||
if [[ $? -eq 60 ]]; then
|
|
||||||
CHOOSE=''
|
|
||||||
read -p "There's an issue with ZJUNET's CA certificates, do you want to do it anyway? [yes/NO] " CHOOSE
|
|
||||||
if [[ $CHOOSE == "YES" ]] || [[ $CHOOSE == "yes" ]]; then
|
|
||||||
RESPONSE=$(curl "https://net.zju.edu.cn/include/auth_action.php" -H "Content-Type: application/x-www-form-urlencoded" -d "action=login&username=${USERNAME}&password=${PASSWORD}&ac_id=3&user_ip=&nas_ip=&user_mac=&save_me=1&ajax=1" -s -k)
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "${RESPONSE}" in
|
|
||||||
*help.html*)
|
|
||||||
echo "Login: success."
|
|
||||||
;;
|
|
||||||
*login_ok*)
|
|
||||||
echo "Login: success."
|
|
||||||
;;
|
|
||||||
*E2532*)
|
|
||||||
echo "Login: failed. Please retry after 10s." >&2
|
|
||||||
echo "Login: ${RESPONSE}" >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Login: failed." >&2
|
|
||||||
if [[ -z "${RESPONSE}" ]]; then
|
|
||||||
echo "Login: (Empty response)" >&2
|
|
||||||
else
|
|
||||||
echo "Login: ${RESPONSE}" >&2
|
|
||||||
fi
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
d|-d|disconnect)
|
|
||||||
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"
|
|
||||||
|
|
||||||
|
|||||||
@ -115,14 +115,14 @@ EOF
|
|||||||
xl2tpd_connect() {
|
xl2tpd_connect() {
|
||||||
echo "[INFO] try connecting $1"
|
echo "[INFO] try connecting $1"
|
||||||
pkill xl2tpd-control > /dev/null
|
pkill xl2tpd-control > /dev/null
|
||||||
xl2tpd-control connect $1 &
|
xl2tpd-control connect-lac $1 &
|
||||||
echo "[INFO] xl2tpd-control done"
|
echo "[INFO] xl2tpd-control done"
|
||||||
}
|
}
|
||||||
|
|
||||||
xl2tpd_disconnect() {
|
xl2tpd_disconnect() {
|
||||||
echo "[INFO] try disconnecting $1"
|
echo "[INFO] try disconnecting $1"
|
||||||
pkill xl2tpd-control > /dev/null
|
pkill xl2tpd-control > /dev/null
|
||||||
xl2tpd-control disconnect $1 &
|
xl2tpd-control disconnect-lac $1 &
|
||||||
echo "[INFO] xl2tpd-control done"
|
echo "[INFO] xl2tpd-control done"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,14 +143,18 @@ xl2tpd_waituser() {
|
|||||||
fi
|
fi
|
||||||
echo -n > $PPP_LOG_FILE
|
echo -n > $PPP_LOG_FILE
|
||||||
|
|
||||||
pid="/var/run/ppp-${LAC_NAME}.pid"
|
for pid in "/var/run/ppp-${LAC_NAME}.pid" \
|
||||||
if [ -e $pid ]; then
|
"/var/run/pppdppp-${LAC_NAME}.pid" \
|
||||||
ppp=$(cat $pid | grep ppp)
|
"/var/run/pppd/ppp-${LAC_NAME}.pid"; do
|
||||||
if ip addr show | grep "inet.*${ppp}" > /dev/null; then
|
if [ -e $pid ]; then
|
||||||
ip addr show | grep "inet.*${ppp}" | sed 's/^ */[VPN] /'
|
ppp=$(cat $pid | grep ppp)
|
||||||
return
|
if ip addr show | grep "inet.*${ppp}" > /dev/null; then
|
||||||
|
ip addr show | grep "inet.*${ppp}" | sed 's/^ */[VPN] /'
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
fi
|
done
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
# zjunet.sh -- router for zjunet
|
# zjunet.sh -- router for zjunet
|
||||||
#
|
#
|
||||||
# Copyright (C) 2014 Zeno Zeng <zenoofzeng@gmail.com>
|
# Copyright (C) 2014 Zeno Zeng <zenoofzeng@gmail.com>
|
||||||
|
# Copyright (C) 2023 Azuk 443 <azukmm@gmail.com>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -64,10 +65,6 @@ Actions:
|
|||||||
vpn, v
|
vpn, v
|
||||||
connect, -c Connect VPN and set up ip route
|
connect, -c Connect VPN and set up ip route
|
||||||
disconnect, -d Disconnect VPN and reset 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
|
route, r Set up static route
|
||||||
dns [ip], d [ip] Test and set up DNS Server (default: 10.10.0.21)
|
dns [ip], d [ip] Test and set up DNS Server (default: 10.10.0.21)
|
||||||
version, -v Display program version
|
version, -v Display program version
|
||||||
@ -76,7 +73,6 @@ Example:
|
|||||||
zjunet user add Add a new user
|
zjunet user add Add a new user
|
||||||
zjunet vpn -c Connect VPN
|
zjunet vpn -c Connect VPN
|
||||||
zjunet vpn -d Disconnect VPN
|
zjunet vpn -d Disconnect VPN
|
||||||
zjunet wlan disable Completely disable WLAN capatibility
|
|
||||||
EOF
|
EOF
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
|
|
||||||
deb http://dl.zjuqsc.com/linux/debian stable main
|
|
||||||
|
|
||||||
@ -1,30 +0,0 @@
|
|||||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
|
||||||
Version: GnuPG v1.4.12 (GNU/Linux)
|
|
||||||
|
|
||||||
mQENBFTWIjMBCADxVTzmEp6T7pT5MiOwcyNQ/AxWf2xsA2ZDugrNrS3GoWRVyowv
|
|
||||||
phmgbq7J394cuL/Yw3f03Mw5mmDDEmC6j+FBf63hlLNj/UOeJdCibOSWJd89gbDY
|
|
||||||
ETUDtWAU+6xlG8gcoi/Jedy+yXwjcD8P8r3xU9pGt6sbJbSUJBzX9ghtEPdygUnn
|
|
||||||
rFG7jHXcbgnCr/mXcCMD59Y0grQvSW6N9B2vyGSrvYU4wlsBAtfJ93PJsd1bG5Oh
|
|
||||||
NS0XOCr4HHZO8hXlSdY2wyce3E2Pk+i/tbRJXoaezsRnHnFO0vAIvyouuIZnu5fr
|
|
||||||
iLIAWlRrErN09UKX4tlcmgWF1NRel3catpT/ABEBAAG0J1FpdSBTaGkgQ2hhbyAo
|
|
||||||
Q09NUDY2KSA8dGVjaEB6anVxc2MuY29tPokBOAQTAQIAIgUCVNYiMwIbAwYLCQgH
|
|
||||||
AwIGFQgCCQoLBBYCAwECHgECF4AACgkQ0qefnxdfAgJfKQgAmtjOp88qBHuguQrb
|
|
||||||
oefHGqs9C/GyJR8uzmlyf2Csln8C1rWJvSuS6J+CDY0jppeHjVJJsNki1RFfIb6p
|
|
||||||
8kFADGHwNMO3xdsMOxUyO9982pt1D0IdnQtn3lg7aWXwWTkdbXeDhOi2eh7BWINd
|
|
||||||
TkYFP6lSanVi2yQEePhAdUv/sNQ2afKmjY+07CRNyCKgBXPPuh2VdWYjKk17Lx2G
|
|
||||||
Jq/Jnw140hE9ESosrqefSnJRlZxjy4h4sE5sl8VPhkYxw91Ol9P9IyfIUx1uPzGc
|
|
||||||
eZAj/nnGNaBjjDzMlsOKVkLptEX4XYmiKVhVby1NkWbO/Makj746lC9TCjVAUgrA
|
|
||||||
Pw4mJLkBDQRU1iIzAQgApukqhnyFmOMvWTSin7NUf3nwNukkKwmABj9b54x+4XcO
|
|
||||||
c6A/9P4GygpqEGyMN6uduxM7PoUA2sPJG2kh2+uZeEoavAGyqfPp2uCFy1SEqopA
|
|
||||||
NyhWJz6bNkTUuHF2V1Wwfm/YIVIvaNKFz1be0t0YZkESuE1KvvEcoUa7BmhHiy7B
|
|
||||||
MiWrom6lFSSprI9t46zeNm9aSWNYAgEtAqgDLkmdmrKUymsIQWTJiSbJV6A3B2FP
|
|
||||||
+euiOozZmLq8bZDI1UgW1aieq0XTpz5ka/uklBKZKe98XmZUTeYmq/Y2xAm9CgJz
|
|
||||||
OXEHgbOJ8bc1r5VnVg2xT2hVA6adw8SI/14tYpntZQARAQABiQEfBBgBAgAJBQJU
|
|
||||||
1iIzAhsMAAoJENKnn58XXwICrWoH/RMEWSnAIYOp8oF4O5N3DT489iTkjZLezdAN
|
|
||||||
ASZwU/AmkFf7HwWiwJ9l9aBVJkbjtmKDNTlBB/dfSyWTZZPER28+d5tAEQp5kr1b
|
|
||||||
n5fm8+A+KHtIN2XclNMS84OpxWJ0RK2bwdc9PAe6iJwKXFTwLIVxUHYdUwLHRluH
|
|
||||||
mpSnQGGoBpEh2711IhBofy/0JXikAi0KqeKia0EHZH4ZrWq5nIygCnVeVfa+SaHw
|
|
||||||
ltjO2awKG1nJB+xjPTRa+lu84qmczrOQ6rKkILUXdHTBaS10rHQbHCa9x8GSIFVs
|
|
||||||
HExKX5SwV9uwcmHN6WVW8zISWZT9qVcvLOcf1cYRWxAHzxKCy0Y=
|
|
||||||
=dTq1
|
|
||||||
-----END PGP PUBLIC KEY BLOCK-----
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
[qsc]
|
|
||||||
name=Several things for Qiu Shi Chao Website
|
|
||||||
baseurl=http://dl.zjuqsc.com/linux/yum
|
|
||||||
failovermethod=priority
|
|
||||||
enabled=1
|
|
||||||
gpgcheck=1
|
|
||||||
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-QSC-COMP66
|
|
||||||
metadata_expire=30m
|
|
||||||
|
|
||||||
@ -1,20 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
command -v apt-key 2>&1 >/dev/null && [ -d /etc/apt ] && {
|
|
||||||
cp /usr/share/zjunet/qsc.list /etc/apt/sources.list.d/qsc.list
|
|
||||||
chmod 644 /etc/apt/sources.list.d/qsc.list
|
|
||||||
apt-key add /usr/share/zjunet/qsc.public.key 2>&1 >/dev/null || true
|
|
||||||
echo "Added apt list."
|
|
||||||
}
|
|
||||||
|
|
||||||
command -v rpm 2>&1 >/dev/null && [ -d /etc/pki/rpm-gpg ] && [ -d /etc/yum.repos.d ] && {
|
|
||||||
cp /usr/share/zjunet/qsc.public.key /etc/pki/rpm-gpg/RPM-GPG-KEY-QSC-COMP66
|
|
||||||
chmod 644 /etc/pki/rpm-gpg/RPM-GPG-KEY-QSC-COMP66
|
|
||||||
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-QSC-COMP66 2>&1 >/dev/null || true
|
|
||||||
cp /usr/share/zjunet/qsc.repo /etc/yum.repos.d/qsc.repo || true
|
|
||||||
echo "Added yum repo."
|
|
||||||
}
|
|
||||||
|
|
||||||
cat <<BANNER
|
cat <<BANNER
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
rm -rIv /usr/local/lib/zjunet
|
PREFIX=/usr/local
|
||||||
rm -iv /usr/local/bin/zjunet
|
|
||||||
|
rm -rIv $PREFIX/lib/zjunet
|
||||||
|
rm -iv $PREFIX/bin/zjunet
|
||||||
|
rm -riv $PREFIX/share/zjunet
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user