From f10b11227e9a2e694b515c847ece7bcf0f78b475 Mon Sep 17 00:00:00 2001 From: Wu Yufei <296820547@qq.com> Date: Tue, 4 Jun 2019 15:44:12 +0800 Subject: [PATCH] Update README and update build system --- .gitignore | 4 ++ README.md | 145 +++++++++++++++++++++++----------------- README.zh.md | 112 +++++++++++++++++++++++++++++++ build/build.sh | 24 ++++--- build/debian/build.sh | 3 +- build/openwrt/build.sh | 3 +- build/rpm/build.sh | 3 +- build/rpm/build_spec.sh | 6 +- 8 files changed, 223 insertions(+), 77 deletions(-) create mode 100644 README.zh.md diff --git a/.gitignore b/.gitignore index 91dc36a..405ce4d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,7 @@ # Rubbish *.swp +build/debian/debian +build/rpm/zjunet-* +build/rpm/zjunet.spec +build/openwrt/debian diff --git a/README.md b/README.md index 4555aa2..ccba4a6 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,22 @@ # zjunet +[查看中文README](README.zh.md) + Command Line Scripts for ZJU (VPN / WLAN / DNS) ## Features - ZJU VPN (l2tp) -- ZJU WLAN +- ZJUWLAN -- 路由器支持(written in Bourne Shell) +- Router support -- 多拨支持(多账户负载均衡) +- Overlap network dialing (with load balance) -- ZJUWLAN 与 ZJUVPN 带宽叠加(1 WLAN + N VPN,在 ZJUWLAN 下) +- Overlap bandwidth of ZJUWLAN and ZJU VPN (1 WLAN + N VPN, Using ZJUWLAN) -- DNS 自动测试设置(适用于 DNS 坏掉的情况) +- Automatic DNS setting (in case DNS do not work) ## Requirements @@ -22,97 +24,116 @@ Command Line Scripts for ZJU (VPN / WLAN / DNS) - curl +- `dig` (Different package on different platform) + ## Install ### Debian / Ubuntu (deb) -Use only one of the methods below: +#### SUGGESTED: From QSC website's linux repository -#### 1. From QSC website's linux repository - - wget -qO - https://dl.zjuqsc.com/linux/qsc.public.key | sudo apt-key add - - sudo wget https://dl.zjuqsc.com/linux/debian/qsc.list -O /etc/apt/sources.list.d/qsc.list - sudo apt-get update - sudo apt-get install zjunet - -#### 2. Download deb -https://github.com/QSCTech/zjunet/releases -下载 deb,双击安装就是。 - -### Fedora / CentOS (rpm) -在 Releases 中下载安装方法如上。注意 CentOS 7 中需要 epel 源提供 xl2tpd - -#### Install from QSC website's linux repository - - sudo wget https://dl.zjuqsc.com/linux/qsc.public.key -O /etc/pki/rpm-gpg/RPM-GPG-KEY-QSC-COMP66 - sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-QSC-COMP66 - sudo wget https://dl.zjuqsc.com/linux/yum/qsc.repo -O /etc/yum.repos.d/qsc.repo - sudo yum install zjunet - - -### Openwrt - -https://github.com/QSCTech/zjunet/releases -下载 opk,然后 `opkg install` 就是。 - -### From source - -master分支是开发分支,请直接从 release 那里获取源码。 - -```bash -cd zjunet -sudo ./install.sh +``` 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 ``` -## Known Issues +#### Alternative: Install .deb package directly -### 丢包 +Download .deb package from [Release Page](https://github.com/QSCTech/zjunet/releases), +Click or run `sudo apt-get install ./zjunet__all.deb` to install. -在有的机子上会丢包(因为用的是 nexthop )。 -等有空了也许会换成 iptables 来解决这个问题。 +### Fedora / CentOS (rpm) -### ppp0 may disappear on openwrt +#### SUGGESTED: From QSC website's linux repository -make /etc/ppp/options's lcp-echo-failure larger. +```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 +``` -see also https://github.com/QSCTech/zjunet/issues/39 +#### Alternative: Install .rpm package directly -## Openwrt +Download .rpm package from [Release Page](https://github.com/QSCTech/zjunet/releases), +Click or run `sudo yum localinstall zjunet-.noarch.rpm` to install. -Install xl2tpd: +**ATTENTION** In CentOS 7, *xl2tpd* requires epel. -https://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/packages/ +### OpenWrt (opk) -## Dev +Download .opk package from [Release Page](https://github.com/QSCTech/zjunet/releases) (onto your router), +Run `opkg install ./zjunet__all.opk`. -QSCer 可以直接向这个 repo push 而不用发 pull request。 -有什么疑虑可以提 issue 问一下, -或者直接来办公室找我(zenozeng)。 +### Other linux (Source Code) -master分支就是开发分支。 -但是请保证bump version的时候要稳定。 +```bash +# 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` +``` -### Build +**ATTENTION** Requirement check will **NOT** be done running `./install.sh`. +Please run `xl2tpd -v`, `curl -V` and `dig -v` to verify the installation. + +## Troubleshooting + +### Packet lose + +This is a known issue. +When overlapping VPN and ZJUWLAN, network packet may be lost. +(because of nexthop in routing table). + +Contributions to this issue are welcomed. (Maybe using `iptables`) + +### ppp0 may disappears on OpenWrt + +Set lcp-echo-failure larger in /etc/ppp/options. + +See also #39 + +### Other problems? + +Please send mail to tech@zjuqsc.com if you have any other problem. + +## Contribute to this project + +QSCers may Push directly without sending Pull Requests。 + +Please write an Issue if you have worries. Contact maintainer directly if necessary. + +**PRs from non-QSCers are also welcomed.** + +### Packaging Instruction + +*(Not finished yet)* #### Debian ```bash -sudo apt-get install build-essential autoconf automake autotools-dev dh-make debhelper devscripts fakeroot xutils lintian pbuilder +sudo apt-get install build-essential autoconf automake autotools-dev dh-make \ + debhelper devscripts fakeroot xutils lintian pbuilder rpm +cd build +./build.sh ``` -##### see also +##### See Also - http://www.webupd8.org/2010/01/how-to-create-deb-package-ubuntu-debian.html - http://tldp.org/HOWTO/html_single/Debian-Binary-Package-Building-HOWTO/ -#### Openwrt +#### OpenWrt -##### see also +##### See Also - http://lists.openmoko.org/pipermail/devel/2008-July/000496.html -## Links +### Links - [Array in unix Bourne Shell](http://unix.stackexchange.com/questions/137566/array-in-unix-bourne-shell) diff --git a/README.zh.md b/README.zh.md new file mode 100644 index 0000000..f18f0e1 --- /dev/null +++ b/README.zh.md @@ -0,0 +1,112 @@ +# zjunet + +适用于 ZJU 的 VPN, WLAN 和 DNS 命令行工具。 + +## 功能 + +- 支持 ZJU VPN 连接。 + +- 支持 ZJUWLAN 连接。 + +- 路由器支持。 + +- 多拨支持(多账户负载均衡)。 + +- ZJUWLAN 与 ZJUVPN 带宽叠加(1 WLAN + N VPN,在 ZJUWLAN 下) + +- DNS 自动测试设置(适用于 DNS 坏掉的情况) + +## 依赖 + +- xl2tpd + +- curl + +- `dig` (在不同平台的包不同) + +## 安装 + +### Debian / Ubuntu (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 +``` + +#### 替代方案:直接安装 deb 包 + +从 [Releases 页](https://github.com/QSCTech/zjunet/releases) 下载 deb 包, +双击安装或运行 `sudo apt-get install ./zjunet_(版本)_all.deb` 。 + +### Fedora / CentOS (rpm) + +#### 推荐:从求是潮网站的仓库下载 + +```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 +``` + +#### 替代方案:直接安装 rpm 包 + +从 [Releases 页](https://github.com/QSCTech/zjunet/releases) 下载 rpm 包, +双击安装或运行 `sudo yum localinstall zjunet-(版本).noarch.rpm` 。 + +**注意** CentOS 7 中需要 epel 源提供 xl2tpd 。 + +### OpenWrt (opk) + +从 [Releases 页](https://github.com/QSCTech/zjunet/releases) 下载 opk 包到路由器上, +运行 `opkg install ./zjunet_(版本)_all.opk` 。 + +### Other linux (源代码安装) + +```bash +# 在合适的目录下 +git clone https://github.com/QSCTech/zjunet.git +cd zjunet +sudo ./install.sh +# 如果想要更新请在 zjunet 目录下运行 git pull 并再次 sudo ./install.sh +``` + +**注意** 运行 `./install.sh` 时 **不会** 确认必要依赖是否已经安装。 +您应当运行 `xl2tpd -v` 、 `curl -V` 和 `dig -v` 确认安装。 + +## 疑难解答 + +### 丢包 + +这是一个已知问题。在同时连接 VPN 和 ZJUWLAN 时, +在有的机子上会丢包(因为设定的路由使用了 nexthop )。 + +暂时没有人来解决这个问题,欢迎有志者贡献(可以考虑用 `iptables` ) + +### OpenWrt 上的 ppp0 消失了 + +将 /etc/ppp/options 中的 lcp-echo-failure 调大。 + +可见于 #39 + +### 我还有其它问题 + +如果你还有其它问题,请与我们联系。 + +您可以发送邮件至 tech@zjuqsc.com 。 + +## 如何贡献 + +求是潮成员可以直接向这个仓库 Push 而不用发起 Pull requests。 + +有任何疑虑都可以提 Issue ,也可以与现任 Maintainer 联系。 + +**本项目也接受非求是潮成员发起的 PR 。** + +### 开发指南 + +开发信息请查看 [英文 README](README.md#packaging-instruction) 。 diff --git a/build/build.sh b/build/build.sh index a370dc1..7d1f11c 100755 --- a/build/build.sh +++ b/build/build.sh @@ -2,16 +2,22 @@ VERSION=$(cat ../VERSION) -cd rpm -./build.sh $VERSION -cd .. +fail() { + echo -e "\033[31mERROR: Failed to build $1\033[0m" 1>&2 +} -cd debian -./build.sh $VERSION -cd .. +pushd rpm > /dev/null +./build.sh $VERSION || fail 'RPM package' +popd > /dev/null -cd openwrt -./build.sh $VERSION +pushd debian > /dev/null +./build.sh $VERSION || fail 'Debian package' +popd > /dev/null -cd .. +pushd openwrt > /dev/null +./build.sh $VERSION || fail 'OpenWrt package' +popd > /dev/null + +echo -ne "\033[0;32m" find . -regextype posix-egrep -regex ".*\.(opk|deb|rpm)$" +echo -ne "\033[0m" diff --git a/build/debian/build.sh b/build/debian/build.sh index e03895c..600d169 100755 --- a/build/debian/build.sh +++ b/build/debian/build.sh @@ -1,4 +1,5 @@ #!/bin/sh +set -e rm -rf *.deb @@ -35,7 +36,7 @@ Version: $VERSION Section: net Priority: optional Architecture: all -Depends: xl2tpd (>= 1.3.1), curl +Depends: xl2tpd (>= 1.3.1), curl, dnsutils Maintainer: Zeno Zeng Description: Command Line Scripts for ZJU This script provides a VPN / WLAN / NEXTHOP for ZJUer. diff --git a/build/openwrt/build.sh b/build/openwrt/build.sh index 7e72394..63faa7a 100755 --- a/build/openwrt/build.sh +++ b/build/openwrt/build.sh @@ -1,4 +1,5 @@ #!/bin/sh +set -e rm -rf *.opk @@ -25,7 +26,7 @@ Version: $VERSION Section: net Priority: optional Architecture: all -Depends: xl2tpd (>= 1.3.1), curl +Depends: xl2tpd (>= 1.3.1), curl, bind-dig Maintainer: Zeno Zeng Description: Command Line Scripts for ZJU This script provides a VPN / WLAN / NEXTHOP for ZJUer. diff --git a/build/rpm/build.sh b/build/rpm/build.sh index 3d63dc7..701de26 100755 --- a/build/rpm/build.sh +++ b/build/rpm/build.sh @@ -1,4 +1,5 @@ #!/bin/sh +set -e rm -rf *.rpm @@ -28,7 +29,7 @@ rm -rf ${SEMINAME}.tar.gz find rpm -type d | xargs chmod 755 rm -rf $SEMINAME mv rpm $SEMINAME -tar zcvf ${SEMINAME}.tar.gz $SEMINAME +tar zcf ${SEMINAME}.tar.gz $SEMINAME mkdir -p $HOME/rpmbuild/SOURCES cp ${SEMINAME}.tar.gz $HOME/rpmbuild/SOURCES cp build_spec.sh $SEMINAME/ diff --git a/build/rpm/build_spec.sh b/build/rpm/build_spec.sh index fc8a0ed..0633fc7 100755 --- a/build/rpm/build_spec.sh +++ b/build/rpm/build_spec.sh @@ -13,7 +13,7 @@ echo "Group: Applications/Internet" >> zjunet.spec echo "URL: https://github.com/QSCTech/zjunet/" >> zjunet.spec echo "Vendor: Qiu Shi Chao Website of Zhejiang University" >> zjunet.spec echo "Packager: Senorsen " >> zjunet.spec -echo "Requires: xl2tpd >= 1.3.1, curl" >> zjunet.spec +echo "Requires: xl2tpd >= 1.3.1, curl, dnsutils" >> zjunet.spec echo "BuildRoot: %{_builddir}/%{name}-root" >> zjunet.spec echo "Source: %{name}-%{version}.tar.gz" >> zjunet.spec echo "BuildArch: noarch" >> zjunet.spec @@ -37,7 +37,7 @@ echo 'install -m 755 zjunet $RPM_BUILD_ROOT/usr/bin/zjunet' >> zjunet.spec echo 'install -m 755 zjunet-postinst $RPM_BUILD_ROOT/usr/share/zjunet/zjunet-postinst' >> zjunet.spec cd lib for f in *.sh; do -echo "install -m 755 lib/$f \$RPM_BUILD_ROOT/usr/lib/zjunet/$f" >> ../zjunet.spec + echo "install -m 755 lib/$f \$RPM_BUILD_ROOT/usr/lib/zjunet/$f" >> ../zjunet.spec done cd .. echo 'install -m 644 VERSION $RPM_BUILD_ROOT/usr/share/zjunet/VERSION' >> zjunet.spec @@ -53,7 +53,7 @@ echo "/usr/share/zjunet/zjunet-postinst" >> zjunet.spec echo "/usr/share/zjunet/VERSION" >> zjunet.spec cd lib for f in *.sh; do -echo "/usr/lib/zjunet/$f" >> ../zjunet.spec + echo "/usr/lib/zjunet/$f" >> ../zjunet.spec done cd .. echo "" >> zjunet.spec