From dc342613a6b95bb228fdc872f978ddd0ca222e2e Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Mon, 12 Nov 2018 18:27:32 +0000 Subject: [PATCH] Add Ubuntu Server 18.04 support --- debian9-x86_64.sh | 80 +++++++++++++++++++++++++++++-------------- glorytun-udp.network | 2 +- glorytun.network | 2 +- mlvpn.network | 2 +- omr-service | 28 +++++++++++---- openvpn.network | 2 +- ubuntu18.04-x86_64.sh | 1 + 7 files changed, 81 insertions(+), 36 deletions(-) create mode 120000 ubuntu18.04-x86_64.sh diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index 25cb156..43314d9 100644 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -7,35 +7,55 @@ OBFS=${OBFS:-no} MLVPN=${MLVPN:-no} OPENVPN=${OPENVPN:-no} INTERFACE=${INTERFACE:-$(ip -o -4 route show to default | grep -Po '(?<=dev )(\S+)' | tr -d "\n")} -DEBIAN_VERSION=$(sed 's/\..*//' /etc/debian_version) -KERNEL_VERSION="4.14.77-mptcp-b3b861b" -OMR_VERSION="0.62" +KERNEL_VERSION="4.14.79-mptcp-0abf4ea" +OMR_VERSION="0.64" set -e umask 0022 -update="0" -if [ $DEBIAN_VERSION -ne 9 ]; then + +# Check Linux version +if test -f /etc/os-release ; then + . /etc/os-release +else + . /usr/lib/os-release +fi +if [ "$ID" = "debian" ] && [ "$VERSION_ID" != "9" ]; then echo "This script only work with Debian Stretch (9.x)" exit 1 +elif [ "$ID" = "ubuntu" ] && [ "$VERSION_ID" != "18.04" ]; then + echo "This script only work with Ubuntu 18.04" + exit 1 +elif [ "$ID" != "debian" ] && [ "$ID" != "ubuntu" ]; then + echo "This script only work with Ubuntu 18.04 or Debian Stretch (9.x)" + exit 1 fi + # Fix old string... -if grep --quiet 'OpenMPCTProuter VPS' /etc/motd ; then +if [ -f /etc/motd ] && grep --quiet 'OpenMPCTProuter VPS' /etc/motd ; then sed -i 's/OpenMPCTProuter/OpenMPTCProuter/g' /etc/motd fi + # Check if OpenMPTCProuter VPS is already installed -if grep --quiet 'OpenMPTCProuter VPS' /etc/motd ; then +update="0" +if [ -f /etc/motd ] && grep --quiet 'OpenMPTCProuter VPS' /etc/motd ; then update="1" -elif grep --quiet 'OpenMPTCProuter VPS' /etc/motd.head ; then +elif [ -f /etc/motd.head ] && grep --quiet 'OpenMPTCProuter VPS' /etc/motd.head ; then update="1" -elif grep --quiet 'OpenMPTCProuter VPS' /root/openmptcprouter_config.txt ; then +elif [ -f /root/openmptcprouter_config.txt ]; then update="1" fi + # Install mptcp kernel and shadowsocks apt-get update apt-get -y install dirmngr patch #apt-key adv --keyserver hkp://keys.gnupg.net --recv-keys 379CE192D401AB61 -#echo 'deb http://dl.bintray.com/cpaasch/deb jessie main' >> /etc/apt/sources.list -echo 'deb http://deb.debian.org/debian stretch-backports main' > /etc/apt/sources.list.d/stretch-backports.list +if [ "$ID" = "debian" ]; then + #echo 'deb http://dl.bintray.com/cpaasch/deb jessie main' >> /etc/apt/sources.list + echo 'deb http://deb.debian.org/debian stretch-backports main' > /etc/apt/sources.list.d/stretch-backports.list +elif [ "$ID" = "ubuntu" ]; then + echo 'deb http://archive.ubuntu.com/ubuntu bionic-backports main' > /etc/apt/sources.list.d/bionic-backports.list + echo 'deb http://archive.ubuntu.com/ubuntu bionic universe' > /etc/apt/sources.list.d/bionic-universe.list +fi apt-get update wget -O /tmp/linux-image-${KERNEL_VERSION}.amd64.deb https://www.openmptcprouter.com/kernel/linux-image-${KERNEL_VERSION}.amd64.deb wget -O /tmp/linux-headers-${KERNEL_VERSION}.amd64.deb https://www.openmptcprouter.com/kernel/linux-headers-${KERNEL_VERSION}.amd64.deb @@ -44,8 +64,8 @@ cd /boot apt-get -y install rename rename 's/^bzImage/vmlinuz/s' * >/dev/null 2>&1 #apt-get -y install linux-mptcp -dpkg -E -i /tmp/linux-image-${KERNEL_VERSION}.amd64.deb -dpkg -E -i /tmp/linux-headers-${KERNEL_VERSION}.amd64.deb +DEBIAN_FRONTEND=noninteractive dpkg --force-confnew -E -i /tmp/linux-image-${KERNEL_VERSION}.amd64.deb +DEBIAN_FRONTEND=noninteractive dpkg --force-confnew -E -i /tmp/linux-headers-${KERNEL_VERSION}.amd64.deb # Check if mptcp kernel is grub default kernel echo "Set MPTCP kernel as grub default..." @@ -55,21 +75,29 @@ bash update-grub.sh ${KERNEL_VERSION} #apt -t stretch-backports -y install shadowsocks-libev ## Compile Shadowsocks -rm -rf /tmp/shadowsocks-libev-3.2.0 -wget -O /tmp/shadowsocks-libev-3.2.0.tar.gz http://github.com/shadowsocks/shadowsocks-libev/releases/download/v3.2.0/shadowsocks-libev-3.2.0.tar.gz +rm -rf /tmp/shadowsocks-libev-3.2.1 +wget -O /tmp/shadowsocks-libev-3.2.1.tar.gz http://github.com/shadowsocks/shadowsocks-libev/releases/download/v3.2.1/shadowsocks-libev-3.2.1.tar.gz cd /tmp -tar xzf shadowsocks-libev-3.2.0.tar.gz -cd shadowsocks-libev-3.2.0 +tar xzf shadowsocks-libev-3.2.1.tar.gz +cd shadowsocks-libev-3.2.1 wget https://raw.githubusercontent.com/Ysurac/openmptcprouter-feeds/master/shadowsocks-libev/patches/020-NOCRYPTO.patch patch -p1 < 020-NOCRYPTO.patch apt-get -y install --no-install-recommends devscripts equivs apg libcap2-bin libpam-cap apt-get -y install libc-ares2 libc-ares-dev libev4 -apt -y -t stretch-backports install libsodium-dev +apt-get -y install haveged +systemctl enable haveged + +if [ "$ID" = "debian" ]; then + apt -y -t stretch-backports install libsodium-dev +elif [ "$ID" = "ubuntu" ]; then + apt-get -y install libsodium-dev + systemctl enable haveged +fi mk-build-deps --install --tool "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" dpkg-buildpackage -b -us -uc cd .. -dpkg -i shadowsocks-libev_3.2.0-1_amd64.deb -rm -rf /tmp/shadowsocks-libev-3.2.0 +dpkg -i shadowsocks-libev_3.2.1-1_amd64.deb +rm -rf /tmp/shadowsocks-libev-3.2.1 # Load OLIA Congestion module at boot time if ! grep -q olia /etc/modules ; then @@ -177,7 +205,11 @@ rm -rf /tmp/glorytun-0.0.99-mud if systemctl -q is-active glorytun-tcp@tun0.service; then systemctl -q stop glorytun-tcp@tun0 > /dev/null 2>&1 fi -apt -t stretch-backports -y install libsodium-dev +if [ "$ID" = "debian" ]; then + apt -t stretch-backports -y install libsodium-dev +elif [ "$ID" = "ubuntu" ]; then + apt-get -y install libsodium-dev +fi apt-get -y install build-essential pkg-config autoconf automake rm -rf /tmp/glorytun-0.0.35 cd /tmp @@ -309,12 +341,10 @@ if [ "$update" = "0" ]; then SSH port: 65222 (instead of port 22) Shadowsocks port: 65101 Shadowsocks encryption: chacha20 - Your shadowsocks key: - ${SHADOWSOCKS_PASS} + Your shadowsocks key: ${SHADOWSOCKS_PASS} Glorytun port: 65001 Glorytun encryption: chacha20 - Your glorytun key: - ${GLORYTUN_PASS} + Your glorytun key: ${GLORYTUN_PASS} EOF if [ -f "/root/openmptcprouter_mlvpn_config.txt" ]; then cat /root/openmptcprouter_mlvpn_config.txt >> /root/openmptcprouter_config.txt diff --git a/glorytun-udp.network b/glorytun-udp.network index fb719c3..39144b4 100644 --- a/glorytun-udp.network +++ b/glorytun-udp.network @@ -9,7 +9,7 @@ IPMasquerade=yes [DHCPServer] PoolOffset=2 -PoolSize=1 +PoolSize=10 EmitDNS=no EmitNTP=no DNS=9.9.9.9 diff --git a/glorytun.network b/glorytun.network index c1fa921..fdee2f4 100644 --- a/glorytun.network +++ b/glorytun.network @@ -12,7 +12,7 @@ IPMasquerade=yes [DHCPServer] PoolOffset=1 -PoolSize=2 +PoolSize=10 EmitDNS=no EmitNTP=no DNS=9.9.9.9 diff --git a/mlvpn.network b/mlvpn.network index 36d4d43..de1e503 100644 --- a/mlvpn.network +++ b/mlvpn.network @@ -9,7 +9,7 @@ IPMasquerade=yes [DHCPServer] PoolOffset=2 -PoolSize=1 +PoolSize=10 EmitDNS=no EmitNTP=no DNS=9.9.9.9 diff --git a/omr-service b/omr-service index 77bfcb1..e4ffd06 100755 --- a/omr-service +++ b/omr-service @@ -32,7 +32,7 @@ ip route replace fd00::/8 via fe80::a00:2 dev omr-6in4 _ping() { local host=$1 ret=$(ping -4 "${host}" \ - -W 5 \ + -W 3 \ -c 1 \ -q ) && echo "$ret" | grep -sq "0% packet loss" && { @@ -41,6 +41,19 @@ _ping() { false } +_ping_range() { + local network=$1 + for i in {2..10} ;do + _ping $network$i + pingr=$? + if $(exit $pingr); then + ipd=$network$i + return + fi + done + false +} + while true; do source /etc/shorewall/params.vpn iface="" @@ -60,8 +73,9 @@ $allip_openvpn $allip_mlvpn" while IFS= read -r inet; do ip=$(echo $inet | awk '{print $2}' | cut -d/ -f1 | tr -d "\n") - ipd=$(echo $ip | sed 's/.1/.2/' | tr -d "\n") - if [ "$ipd" != "" ]; then + _ping_range $(echo $ip | sed 's/.1/./' | tr -d "\n") + statusr=$? + if $(exit $statusr); then _ping $ipd statusp=$? if $(exit $statusp); then @@ -75,10 +89,10 @@ $allip_mlvpn" fi fi done < <(printf '%s\n' "$allip") - [ -z "$iface" ] && { - systemctl -q restart systemd-networkd - sleep 10 - } + #[ -z "$iface" ] && { + # systemctl -q restart systemd-networkd + # sleep 10 + #} fi fi sleep 5 diff --git a/openvpn.network b/openvpn.network index abdbd70..268744c 100644 --- a/openvpn.network +++ b/openvpn.network @@ -9,7 +9,7 @@ IPMasquerade=yes [DHCPServer] PoolOffset=2 -PoolSize=1 +PoolSize=10 EmitDNS=no EmitNTP=no DNS=9.9.9.9 diff --git a/ubuntu18.04-x86_64.sh b/ubuntu18.04-x86_64.sh new file mode 120000 index 0000000..814a06c --- /dev/null +++ b/ubuntu18.04-x86_64.sh @@ -0,0 +1 @@ +debian9-x86_64.sh \ No newline at end of file