From 3c6e85e07fb7d6f9019e2aea7e76cf25da392401 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 10 Mar 2021 10:23:46 +0100 Subject: [PATCH 01/32] Add a service to do update after reboot --- debian/postinst | 6 ++++-- debian/rules | 3 ++- debian9-x86_64.sh | 7 +++++++ omr-update.service.in | 14 ++++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 omr-update.service.in diff --git a/debian/postinst b/debian/postinst index 66b1e91..3f2400b 100644 --- a/debian/postinst +++ b/debian/postinst @@ -5,8 +5,10 @@ test $DEBIAN_SCRIPT_DEBUG && set -v -x # use debconf . /usr/share/debconf/confmodule -cd /usr/share/omr-server -LOCALFILES=no SOURCES=no sh debian9-x86_64.sh +sed -i -e "s/^LOCALFILES=.*$/LOCALFILES=no/" -e "s/^SOURCES=.*$/SOURCES=no/" debian9-x86_64.sh +echo 'To finish installation reboot' + +systemctl enable omr-update db_stop diff --git a/debian/rules b/debian/rules index 10d24ab..4db8990 100755 --- a/debian/rules +++ b/debian/rules @@ -9,8 +9,9 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all override_dh_auto_install: mkdir -p $(CURDIR)/debian/omr-server/usr/share/omr-server - find . -type f -not -iname '*/debian/*' -not -iname '*/.git/*' -exec cp '{}' "$(CURDIR)/debian/omr-server/usr/share/omr-server/{}" ';' + find . -type f -xtype f -not -iname '*/debian/*' -not -iname '*/.git/*' -exec cp '{}' "$(CURDIR)/debian/omr-server/usr/share/omr-server/{}" ';' cp -r ./shorewall4 $(CURDIR)/debian/omr-server/usr/share/omr-server/ cp -r ./shorewall6 $(CURDIR)/debian/omr-server/usr/share/omr-server/ cp -r ./bin $(CURDIR)/debian/omr-server/usr/share/omr-server/ + cp omr-update.service.in /lib/systemd/system/omr-update.service diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index c052fbf..c805f90 100644 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -30,6 +30,7 @@ DSVPN=${DSVPN:-yes} WIREGUARD=${WIREGUARD:-yes} SOURCES=${SOURCES:-yes} NOINTERNET=${NOINTERNET:-no} +REINSTALL=${REINSTALL:-yes} SPEEDTEST=${SPEEDTEST:-no} LOCALFILES=${LOCALFILES:-no} INTERFACE=${INTERFACE:-$(ip -o -4 route show to default | grep -m 1 -Po '(?<=dev )(\S+)' | tr -d "\n")} @@ -133,6 +134,12 @@ if [ "$UPDATE" = "yes" ]; then echo "Update mode" fi +CURRENT_OMR="$(grep -s 'OpenMPTCProuter VPS' /etc/* | awk '{print $4}')" +if [ "$REINSTALL" = "no" ] && [ "$CURRENT_OMR" = "$OMR_VERSION" ]; then + exit 1 +fi + + echo "Remove lock and update packages list..." rm -f /var/lib/dpkg/lock rm -f /var/lib/dpkg/lock-frontend diff --git a/omr-update.service.in b/omr-update.service.in new file mode 100644 index 0000000..c543d73 --- /dev/null +++ b/omr-update.service.in @@ -0,0 +1,14 @@ +[Unit] +Description=OMR Update +After=network.target network-online.target + +[Service] +Type=simple +Restart=no +Environment="SOURCES=no" +Environment="REINSTALL=no" +Environment="LOCALFILES=yes" +ExecStart=/usr/share/omr-server/debian9-x86_64.sh + +[Install] +WantedBy=multi-user.target From 0ddc538c87294424b9c2f5b06fac9469d273c08a Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 10 Mar 2021 09:29:59 +0000 Subject: [PATCH 02/32] Add dependencie in debian package --- debian/control | 2 ++ 1 file changed, 2 insertions(+) diff --git a/debian/control b/debian/control index fccd12e..37756a6 100644 --- a/debian/control +++ b/debian/control @@ -27,6 +27,8 @@ Depends: shorewall, shorewall6, iptables, + v2ray-plugin, + linux-image (= 5.4.100-mptcp_1.18+9d3f35b), ${misc:Depends} Provides: omr-server Conflicts: omr-server From 96eb181b403ad71405bf3717eb476e6799bd0dbb Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 10 Mar 2021 09:30:19 +0000 Subject: [PATCH 03/32] Use Debian package for kernel --- debian9-x86_64.sh | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index c052fbf..cdd7d57 100644 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -194,22 +194,29 @@ apt-get update sleep 2 apt-get -y install dirmngr patch -wget -O /tmp/linux-image-${KERNEL_RELEASE}_amd64.deb ${VPSURL}kernel/linux-image-${KERNEL_RELEASE}_amd64.deb -wget -O /tmp/linux-headers-${KERNEL_RELEASE}_amd64.deb ${VPSURL}kernel/linux-headers-${KERNEL_RELEASE}_amd64.deb -# Rename bzImage to vmlinuz, needed when custom kernel was used -cd /boot -apt-get -y install rename curl libcurl4 unzip git -rename 's/^bzImage/vmlinuz/s' * >/dev/null 2>&1 -#apt-get -y install linux-mptcp -#dpkg --remove --force-remove-reinstreq linux-image-${KERNEL_VERSION}-mptcp -#dpkg --remove --force-remove-reinstreq linux-headers-${KERNEL_VERSION}-mptcp -if [ "$(dpkg -l | grep linux-image-${KERNEL_VERSION} | grep ${KERNEL_PACKAGE_VERSION})" = "" ]; then +if [ "$SOURCES" = "yes" ]; then + wget -O /tmp/linux-image-${KERNEL_RELEASE}_amd64.deb ${VPSURL}kernel/linux-image-${KERNEL_RELEASE}_amd64.deb + wget -O /tmp/linux-headers-${KERNEL_RELEASE}_amd64.deb ${VPSURL}kernel/linux-headers-${KERNEL_RELEASE}_amd64.deb + # Rename bzImage to vmlinuz, needed when custom kernel was used + cd /boot + apt-get -y install rename curl libcurl4 unzip git + rename 's/^bzImage/vmlinuz/s' * >/dev/null 2>&1 + #apt-get -y install linux-mptcp + #dpkg --remove --force-remove-reinstreq linux-image-${KERNEL_VERSION}-mptcp + #dpkg --remove --force-remove-reinstreq linux-headers-${KERNEL_VERSION}-mptcp + if [ "$(dpkg -l | grep linux-image-${KERNEL_VERSION} | grep ${KERNEL_PACKAGE_VERSION})" = "" ]; then + echo "Install kernel linux-image-${KERNEL_RELEASE}" + echo "\033[1m !!! if kernel install fail run: dpkg --remove --force-remove-reinstreq linux-image-${KERNEL_VERSION}-mptcp !!! \033[0m" + dpkg --force-all -i -B /tmp/linux-headers-${KERNEL_RELEASE}_amd64.deb + dpkg --force-all -i -B /tmp/linux-image-${KERNEL_RELEASE}_amd64.deb + fi +else + cd /boot + rename 's/^bzImage/vmlinuz/s' * >/dev/null 2>&1 echo "Install kernel linux-image-${KERNEL_RELEASE}" echo "\033[1m !!! if kernel install fail run: dpkg --remove --force-remove-reinstreq linux-image-${KERNEL_VERSION}-mptcp !!! \033[0m" - dpkg --force-all -i -B /tmp/linux-headers-${KERNEL_RELEASE}_amd64.deb - dpkg --force-all -i -B /tmp/linux-image-${KERNEL_RELEASE}_amd64.deb + apt-get -y install linux-image=${KERNEL_RELEASE} linux-headers=${KERNEL_RELEASE} fi - # Check if mptcp kernel is grub default kernel echo "Set MPTCP kernel as grub default..." if [ "$LOCALFILES" = "no" ]; then @@ -594,7 +601,11 @@ fi if [ "$V2RAY" = "yes" ]; then #apt-get -y -o Dpkg::Options::="--force-overwrite" install v2ray - wget -O /tmp/v2ray-${V2RAY_VERSION}-amd64.deb ${VPSURL}/debian/v2ray-${V2RAY_VERSION}-amd64.deb + if [ "$SOURCES" = "yes" ]; then + wget -O /tmp/v2ray-${V2RAY_VERSION}-amd64.deb ${VPSURL}/debian/v2ray-${V2RAY_VERSION}-amd64.deb + else + apt-get -y install v2ray=${V2RAY_VERSION} + fi if [ -f /etc/v2ray/v2ray-server.conf ] && [ ! -f /etc/systemd/system/v2ray.service ]; then wget -O /etc/systemd/system/v2ray.service ${VPSURL}${VPSPATH}/old-v2ray.service fi From cf1eca052a1107562c6d0980857c65330864c442 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 10 Mar 2021 09:33:15 +0000 Subject: [PATCH 04/32] Fix kernel package version --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 37756a6..17c4b9b 100644 --- a/debian/control +++ b/debian/control @@ -28,7 +28,7 @@ Depends: shorewall6, iptables, v2ray-plugin, - linux-image (= 5.4.100-mptcp_1.18+9d3f35b), + linux-image-5.4.100-mptcp (= 1.18+9d3f35b), ${misc:Depends} Provides: omr-server Conflicts: omr-server From 605acd1ffdda1154e0233b02dec267a3f450ae14 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 10 Mar 2021 09:35:54 +0000 Subject: [PATCH 05/32] Fix kernel package version in install script --- debian9-x86_64.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index 72760df..30cb01c 100644 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -222,7 +222,7 @@ else rename 's/^bzImage/vmlinuz/s' * >/dev/null 2>&1 echo "Install kernel linux-image-${KERNEL_RELEASE}" echo "\033[1m !!! if kernel install fail run: dpkg --remove --force-remove-reinstreq linux-image-${KERNEL_VERSION}-mptcp !!! \033[0m" - apt-get -y install linux-image=${KERNEL_RELEASE} linux-headers=${KERNEL_RELEASE} + apt-get -y install linux-image-${KERNEL_VERSION}-mptcp=${KERNEL_PACKAGE_VERSION} linux-headers-${KERNEL_VERSION}-mptcp=${KERNEL_PACKAGE_VERSION} fi # Check if mptcp kernel is grub default kernel echo "Set MPTCP kernel as grub default..." From 95453a801372c2db4b608fd84e6250ef2e694ee6 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 10 Mar 2021 09:51:50 +0000 Subject: [PATCH 06/32] Fix sed in debian package --- debian/postinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/postinst b/debian/postinst index 3f2400b..03edb58 100644 --- a/debian/postinst +++ b/debian/postinst @@ -5,7 +5,7 @@ test $DEBIAN_SCRIPT_DEBUG && set -v -x # use debconf . /usr/share/debconf/confmodule -sed -i -e "s/^LOCALFILES=.*$/LOCALFILES=no/" -e "s/^SOURCES=.*$/SOURCES=no/" debian9-x86_64.sh +sed -i -e "s/^LOCALFILES=.*$/LOCALFILES=no/" -e "s/^SOURCES=.*$/SOURCES=no/" /usr/share/omr-server/debian9-x86_64.sh echo 'To finish installation reboot' systemctl enable omr-update From 382fc59a4f87cc6789a7dd18641a46fa733a1ad0 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 10 Mar 2021 10:30:05 +0000 Subject: [PATCH 07/32] Fix v2ray --- debian9-x86_64.sh | 4 ++-- old-v2ray.service | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) mode change 100644 => 100755 debian9-x86_64.sh create mode 100644 old-v2ray.service diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh old mode 100644 new mode 100755 index 30cb01c..bc28a86 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -610,14 +610,14 @@ if [ "$V2RAY" = "yes" ]; then #apt-get -y -o Dpkg::Options::="--force-overwrite" install v2ray if [ "$SOURCES" = "yes" ]; then wget -O /tmp/v2ray-${V2RAY_VERSION}-amd64.deb ${VPSURL}/debian/v2ray-${V2RAY_VERSION}-amd64.deb + dpkg --force-all -i -B /tmp/v2ray-${V2RAY_VERSION}-amd64.deb + rm -f /tmp/v2ray-${V2RAY_VERSION}-amd64.deb else apt-get -y install v2ray=${V2RAY_VERSION} fi if [ -f /etc/v2ray/v2ray-server.conf ] && [ ! -f /etc/systemd/system/v2ray.service ]; then wget -O /etc/systemd/system/v2ray.service ${VPSURL}${VPSPATH}/old-v2ray.service fi - dpkg --force-all -i -B /tmp/v2ray-${V2RAY_VERSION}-amd64.deb - rm -f /tmp/v2ray-${V2RAY_VERSION}-amd64.deb if [ ! -f /etc/v2ray/v2ray-server.json ]; then wget -O /etc/v2ray/v2ray-server.json ${VPSURL}${VPSPATH}/v2ray-server.json sed -i "s:V2RAY_UUID:$V2RAY_UUID:g" /etc/v2ray/v2ray-server.json diff --git a/old-v2ray.service b/old-v2ray.service new file mode 100644 index 0000000..9ed715a --- /dev/null +++ b/old-v2ray.service @@ -0,0 +1,25 @@ +[Unit] +Description=V2Ray - A unified platform for anti-censorship +Documentation=https://v2ray.com https://guide.v2fly.org +After=network.target nss-lookup.target +Wants=network-online.target + +[Service] +# If the version of systemd is 240 or above, then uncommenting Type=exec and commenting out Type=simple +#Type=exec +Type=simple +# Runs as root or add CAP_NET_BIND_SERVICE ability can bind 1 to 1024 port. +# This service runs as root. You may consider to run it as another user for security concerns. +# By uncommenting User=v2ray and commenting out User=root, the service will run as user v2ray. +# More discussion at https://github.com/v2ray/v2ray-core/issues/1011 +User=root +#User=v2ray +CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_NET_RAW +NoNewPrivileges=yes +ExecStart=/usr/bin/v2ray -config /etc/v2ray/config.json +Restart=on-failure +# Don't restart in the case of configuration error +RestartPreventExitStatus=23 + +[Install] +WantedBy=multi-user.target From f573c43ce0f1a587b9452aa10641d5dd4cb97342 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 10 Mar 2021 10:30:32 +0000 Subject: [PATCH 08/32] Fix omr-update service script install --- debian/rules | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/debian/rules b/debian/rules index 4db8990..d411dc4 100755 --- a/debian/rules +++ b/debian/rules @@ -13,5 +13,6 @@ override_dh_auto_install: cp -r ./shorewall4 $(CURDIR)/debian/omr-server/usr/share/omr-server/ cp -r ./shorewall6 $(CURDIR)/debian/omr-server/usr/share/omr-server/ cp -r ./bin $(CURDIR)/debian/omr-server/usr/share/omr-server/ - cp omr-update.service.in /lib/systemd/system/omr-update.service + mkdir -p $(CURDIR)/debian/omr-server/lib/systemd/system + cp omr-update.service.in $(CURDIR)/debian/omr-server/lib/systemd/system/omr-update.service From 2dbc4e4f0fab5a029a4693a0bab2740e34b3beb0 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 10 Mar 2021 10:31:20 +0000 Subject: [PATCH 09/32] Fix output of omr-update --- omr-update.service.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/omr-update.service.in b/omr-update.service.in index c543d73..1a21135 100644 --- a/omr-update.service.in +++ b/omr-update.service.in @@ -9,6 +9,8 @@ Environment="SOURCES=no" Environment="REINSTALL=no" Environment="LOCALFILES=yes" ExecStart=/usr/share/omr-server/debian9-x86_64.sh +StandardOutput=file:/var/log/omr-update.log +StandardError=file:/var/log/omr-update.log [Install] WantedBy=multi-user.target From 8e795b035b46cb5175131a7e2d047ab110c8d82e Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 10 Mar 2021 13:00:31 +0000 Subject: [PATCH 10/32] Reboot not needed after install --- debian/postinst | 2 -- 1 file changed, 2 deletions(-) diff --git a/debian/postinst b/debian/postinst index 03edb58..bd08d7f 100644 --- a/debian/postinst +++ b/debian/postinst @@ -6,8 +6,6 @@ test $DEBIAN_SCRIPT_DEBUG && set -v -x . /usr/share/debconf/confmodule sed -i -e "s/^LOCALFILES=.*$/LOCALFILES=no/" -e "s/^SOURCES=.*$/SOURCES=no/" /usr/share/omr-server/debian9-x86_64.sh -echo 'To finish installation reboot' - systemctl enable omr-update db_stop From 5bfd42770dfd6cb9d304ffccda4bdd2ebb52b197 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 10 Mar 2021 13:00:54 +0000 Subject: [PATCH 11/32] Fix get previous pass for omr-admin --- debian9-x86_64.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index bc28a86..837d4d6 100755 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -450,9 +450,9 @@ if [ "$OMR_ADMIN" = "yes" ]; then if [ -f /etc/openmptcprouter-vps-admin/omr-admin-config.json ]; then OMR_ADMIN_PASS2=$(grep -Po '"'"pass"'"\s*:\s*"\K([^"]*)' /etc/openmptcprouter-vps-admin/omr-admin-config.json | tr -d "\n") [ -z "$OMR_ADMIN_PASS2" ] && OMR_ADMIN_PASS2=$(cat /etc/openmptcprouter-vps-admin/omr-admin-config.json | jq -r .users[0].openmptcprouter.user_password | tr -d "\n") - [ -n "$OMR_ADMIN_PASS2" ] && OMR_ADMIN_PASS=$OMR_ADMIN_PASS2 + [ -n "$OMR_ADMIN_PASS2" ] && [ "$OMR_ADMIN_PASS2" != "MySecretKey" ] && OMR_ADMIN_PASS=$OMR_ADMIN_PASS2 OMR_ADMIN_PASS_ADMIN2=$(cat /etc/openmptcprouter-vps-admin/omr-admin-config.json | jq -r .users[0].admin.user_password | tr -d "\n") - [ -n "$OMR_ADMIN_PASS_ADMIN2" ] && OMR_ADMIN_PASS_ADMIN=$OMR_ADMIN_PASS_ADMIN2 + [ -n "$OMR_ADMIN_PASS_ADMIN2" ] && [ "$OMR_ADMIN_PASS_ADMIN2" != "AdminMySecretKey" ] && OMR_ADMIN_PASS_ADMIN=$OMR_ADMIN_PASS_ADMIN2 fi apt-get -y install omr-vps-admin=${OMR_ADMIN_BINARY_VERSION} if [ ! -f /etc/openmptcprouter-vps-admin/omr-admin-config.json ]; then From 269b986cbe12f4cb8166fe88ed0f9f29ca800da9 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 10 Mar 2021 13:04:17 +0000 Subject: [PATCH 12/32] Install omr-server debian package at end of install script --- debian9-x86_64.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index 837d4d6..b7e98d2 100755 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -1219,6 +1219,10 @@ else echo "< OpenMPTCProuter VPS $OMR_VERSION >" > /etc/motd fi +if [ "$SOURCES" != "yes" ]; then + apt-get -y install omr-server=${OMR_VERSION} +fi + if [ "$update" = "0" ]; then # Display important info echo '====================================================================================' From 7ce28a948188cfc8b3a40b30fc68d7e0f714bf8f Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 10 Mar 2021 13:43:18 +0000 Subject: [PATCH 13/32] Fix script for kernel binary install --- debian9-x86_64.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index b7e98d2..f8b3f97 100755 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -199,14 +199,14 @@ fi echo "Install mptcp kernel and shadowsocks..." apt-get update sleep 2 -apt-get -y install dirmngr patch +apt-get -y install dirmngr patch rename curl libcurl4 unzip if [ "$SOURCES" = "yes" ]; then wget -O /tmp/linux-image-${KERNEL_RELEASE}_amd64.deb ${VPSURL}kernel/linux-image-${KERNEL_RELEASE}_amd64.deb wget -O /tmp/linux-headers-${KERNEL_RELEASE}_amd64.deb ${VPSURL}kernel/linux-headers-${KERNEL_RELEASE}_amd64.deb # Rename bzImage to vmlinuz, needed when custom kernel was used cd /boot - apt-get -y install rename curl libcurl4 unzip git + apt-get -y install git rename 's/^bzImage/vmlinuz/s' * >/dev/null 2>&1 #apt-get -y install linux-mptcp #dpkg --remove --force-remove-reinstreq linux-image-${KERNEL_VERSION}-mptcp @@ -220,9 +220,11 @@ if [ "$SOURCES" = "yes" ]; then else cd /boot rename 's/^bzImage/vmlinuz/s' * >/dev/null 2>&1 - echo "Install kernel linux-image-${KERNEL_RELEASE}" - echo "\033[1m !!! if kernel install fail run: dpkg --remove --force-remove-reinstreq linux-image-${KERNEL_VERSION}-mptcp !!! \033[0m" - apt-get -y install linux-image-${KERNEL_VERSION}-mptcp=${KERNEL_PACKAGE_VERSION} linux-headers-${KERNEL_VERSION}-mptcp=${KERNEL_PACKAGE_VERSION} + if [ "$(dpkg -l | grep linux-image-${KERNEL_VERSION} | grep ${KERNEL_PACKAGE_VERSION})" = "" ]; then + echo "Install kernel linux-image-${KERNEL_RELEASE}" + echo "\033[1m !!! if kernel install fail run: dpkg --remove --force-remove-reinstreq linux-image-${KERNEL_VERSION}-mptcp !!! \033[0m" + apt-get -y install linux-image-${KERNEL_VERSION}-mptcp=${KERNEL_PACKAGE_VERSION} linux-headers-${KERNEL_VERSION}-mptcp=${KERNEL_PACKAGE_VERSION} + fi fi # Check if mptcp kernel is grub default kernel echo "Set MPTCP kernel as grub default..." From a713d44645de0311a8289bd0b9a8b77ef5c2163d Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 10 Mar 2021 13:46:55 +0000 Subject: [PATCH 14/32] No error if omr-server not installed --- debian9-x86_64.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index f8b3f97..8c2fb45 100755 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -1222,7 +1222,7 @@ else fi if [ "$SOURCES" != "yes" ]; then - apt-get -y install omr-server=${OMR_VERSION} + apt-get -y install omr-server=${OMR_VERSION} 2>&1 >/dev/null || true fi if [ "$update" = "0" ]; then From e70303ba3f1be88a0259ee94e4d90037bcde0cec Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 10 Mar 2021 14:11:54 +0000 Subject: [PATCH 15/32] Change version --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 1e55a02..33cf21b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -omr-server (0.1025) unstable; urgency=medium +omr-server (0.1025-test) unstable; urgency=medium * Wireguard support and fixed From 8856fece584efb8c4244899d43a24461e98ffefb Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 10 Mar 2021 14:38:35 +0000 Subject: [PATCH 16/32] Use v2ray_plugin debian package --- debian/control | 3 ++- debian9-x86_64.sh | 52 +++++++++++++++++++++++++---------------------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/debian/control b/debian/control index 17c4b9b..0da3629 100644 --- a/debian/control +++ b/debian/control @@ -27,7 +27,8 @@ Depends: shorewall, shorewall6, iptables, - v2ray-plugin, + v2ray-plugin (= 4.35.1), + v2ray (=4.35.1), linux-image-5.4.100-mptcp (= 1.18+9d3f35b), ${misc:Depends} Provides: omr-server diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index 8c2fb45..fd83af2 100755 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -50,8 +50,8 @@ OMR_ADMIN_VERSION="2e752ad783ffb817f6d627a999d51ac6656411f9" OMR_ADMIN_BINARY_VERSION="0.3+20210304" DSVPN_VERSION="3b99d2ef6c02b2ef68b5784bec8adfdd55b29b1a" DSVPN_BINARY_VERSION="0.1.4-2" -V2RAY_VERSION="4.34.0" -V2RAY_PLUGIN_VERSION="v1.4.3" +V2RAY_VERSION="4.35.1" +V2RAY_PLUGIN_VERSION="4.35.1" EASYRSA_VERSION="3.0.6" SHADOWSOCKS_VERSION="cadf278d476d0e5679c3e67390b271276a8dc54a" SHADOWSOCKS_BINARY_VERSION="3.3.5-1" @@ -574,29 +574,33 @@ fi # Install v2ray-plugin if [ "$V2RAY_PLUGIN" = "yes" ]; then echo "Install v2ray plugin" - rm -rf /tmp/v2ray-plugin-linux-amd64-${V2RAY_PLUGIN_VERSION}.tar.gz - #wget -O /tmp/v2ray-plugin-linux-amd64-${V2RAY_PLUGIN_VERSION}.tar.gz https://github.com/shadowsocks/v2ray-plugin/releases/download/${V2RAY_PLUGIN_VERSION}/v2ray-plugin-linux-amd64-${V2RAY_PLUGIN_VERSION}.tar.gz - #wget -O /tmp/v2ray-plugin-linux-amd64-${V2RAY_PLUGIN_VERSION}.tar.gz ${VPSURL}${VPSPATH}/bin/v2ray-plugin-linux-amd64-${V2RAY_PLUGIN_VERSION}.tar.gz - wget -O /tmp/v2ray-plugin-linux-amd64-${V2RAY_PLUGIN_VERSION}.tar.gz https://github.com/teddysun/v2ray-plugin/releases/download/v1.4.3/v2ray-plugin-linux-amd64-${V2RAY_PLUGIN_VERSION}.tar.gz - cd /tmp - tar xzvf v2ray-plugin-linux-amd64-${V2RAY_PLUGIN_VERSION}.tar.gz - cp -f v2ray-plugin_linux_amd64 /usr/local/bin/v2ray-plugin - cd /tmp - rm -rf /tmp/v2ray-plugin_linux_amd64 - rm -rf /tmp/v2ray-plugin-linux-amd64-${V2RAY_PLUGIN_VERSION}.tar.gz + if [ "$SOURCES" = "yes" ]; then + rm -rf /tmp/v2ray-plugin-linux-amd64-${V2RAY_PLUGIN_VERSION}.tar.gz + #wget -O /tmp/v2ray-plugin-linux-amd64-v${V2RAY_PLUGIN_VERSION}.tar.gz https://github.com/shadowsocks/v2ray-plugin/releases/download/${V2RAY_PLUGIN_VERSION}/v2ray-plugin-linux-amd64-v${V2RAY_PLUGIN_VERSION}.tar.gz + #wget -O /tmp/v2ray-plugin-linux-amd64-v${V2RAY_PLUGIN_VERSION}.tar.gz ${VPSURL}${VPSPATH}/bin/v2ray-plugin-linux-amd64-v${V2RAY_PLUGIN_VERSION}.tar.gz + wget -O /tmp/v2ray-plugin-linux-amd64-v${V2RAY_PLUGIN_VERSION}.tar.gz https://github.com/teddysun/v2ray-plugin/releases/download/v1.4.3/v2ray-plugin-linux-amd64-v${V2RAY_PLUGIN_VERSION}.tar.gz + cd /tmp + tar xzvf v2ray-plugin-linux-amd64-v${V2RAY_PLUGIN_VERSION}.tar.gz + cp -f v2ray-plugin_linux_amd64 /usr/local/bin/v2ray-plugin + cd /tmp + rm -rf /tmp/v2ray-plugin_linux_amd64 + rm -rf /tmp/v2ray-plugin-linux-amd64-${V2RAY_PLUGIN_VERSION}.tar.gz - #rm -rf /tmp/v2ray-plugin - #cd /tmp - #rm -f /var/lib/dpkg/lock - #apt-get install -y --no-install-recommends git ca-certificates golang-go - #git clone https://github.com/shadowsocks/v2ray-plugin.git /tmp/v2ray-plugin - #cd /tmp/v2ray-plugin - #git checkout ${V2RAY_PLUGIN_VERSION} - #git submodule update --init --recursive - #CGO_ENABLED=0 go build -o v2ray-plugin - #cp v2ray-plugin /usr/local/bin/v2ray-plugin - #cd /tmp - #rm -rf /tmp/simple-obfs + #rm -rf /tmp/v2ray-plugin + #cd /tmp + #rm -f /var/lib/dpkg/lock + #apt-get install -y --no-install-recommends git ca-certificates golang-go + #git clone https://github.com/shadowsocks/v2ray-plugin.git /tmp/v2ray-plugin + #cd /tmp/v2ray-plugin + #git checkout ${V2RAY_PLUGIN_VERSION} + #git submodule update --init --recursive + #CGO_ENABLED=0 go build -o v2ray-plugin + #cp v2ray-plugin /usr/local/bin/v2ray-plugin + #cd /tmp + #rm -rf /tmp/simple-obfs + else + apt-get -y install v2ray-plugin=${V2RAY_PLUGIN_VERSION} + fi fi if [ "$OBFS" = "no" ] && [ "$V2RAY_PLUGIN" = "no" ]; then From 47df28fdc67b2f5927da84924d18edd8c4ec1133 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Thu, 11 Mar 2021 08:07:55 +0000 Subject: [PATCH 17/32] Fix symbolic link for v2ray config --- debian9-x86_64.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index fd83af2..3706227 100755 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -630,6 +630,7 @@ if [ "$V2RAY" = "yes" ]; then rm /etc/v2ray/config.json ln -s /etc/v2ray/v2ray-server.json /etc/v2ray/config.json fi + ln -sf /etc/v2ray/v2ray-server.json /etc/v2ray/config.json sed -i 's:debug:warning:' /etc/v2ray/v2ray-server.json rm -f /tmp/v2rayError.log if [ -f /etc/systemd/system/v2ray.service.dpkg-dist ]; then From 83e81cfd9ffb14d8495a8f210d3a9854e52d84bb Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Thu, 11 Mar 2021 14:48:12 +0000 Subject: [PATCH 18/32] Go to openmptcprouter-vps-admin dir before creating key --- debian9-x86_64.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index 3706227..4be25a4 100755 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -464,6 +464,7 @@ if [ "$OMR_ADMIN" = "yes" ]; then #OMR_ADMIN_PASS_ADMIN=$(cat /etc/openmptcprouter-vps-admin/omr-admin-config.json | jq -r .users[0].admin.user_password | tr -d "\n") fi if [ ! -f /etc/openmptcprouter-vps-admin/key.pem ]; then + cd /etc/openmptcprouter-vps-admin openssl req -new -newkey rsa:2048 -days 3650 -nodes -x509 -keyout key.pem -out cert.pem -subj "/C=US/ST=Oregon/L=Portland/O=OpenMPTCProuterVPS/OU=Org/CN=www.openmptcprouter.vps" fi sed -i "s:openmptcptouter:${DEFAULT_USER}:g" /etc/openmptcprouter-vps-admin/omr-admin-config.json From 8e738a8f197f823f1ac6a0cee5e1b81f16fcf21f Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Fri, 12 Mar 2021 06:46:05 +0000 Subject: [PATCH 19/32] Fix https://github.com/Ysurac/openmptcprouter-vps/issues/46 --- debian9-x86_64.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index 4be25a4..2d1af03 100755 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -579,7 +579,7 @@ if [ "$V2RAY_PLUGIN" = "yes" ]; then rm -rf /tmp/v2ray-plugin-linux-amd64-${V2RAY_PLUGIN_VERSION}.tar.gz #wget -O /tmp/v2ray-plugin-linux-amd64-v${V2RAY_PLUGIN_VERSION}.tar.gz https://github.com/shadowsocks/v2ray-plugin/releases/download/${V2RAY_PLUGIN_VERSION}/v2ray-plugin-linux-amd64-v${V2RAY_PLUGIN_VERSION}.tar.gz #wget -O /tmp/v2ray-plugin-linux-amd64-v${V2RAY_PLUGIN_VERSION}.tar.gz ${VPSURL}${VPSPATH}/bin/v2ray-plugin-linux-amd64-v${V2RAY_PLUGIN_VERSION}.tar.gz - wget -O /tmp/v2ray-plugin-linux-amd64-v${V2RAY_PLUGIN_VERSION}.tar.gz https://github.com/teddysun/v2ray-plugin/releases/download/v1.4.3/v2ray-plugin-linux-amd64-v${V2RAY_PLUGIN_VERSION}.tar.gz + wget -O /tmp/v2ray-plugin-linux-amd64-v${V2RAY_PLUGIN_VERSION}.tar.gz https://github.com/teddysun/v2ray-plugin/releases/download/v${V2RAY_PLUGIN_VERSION}/v2ray-plugin-linux-amd64-v${V2RAY_PLUGIN_VERSION}.tar.gz cd /tmp tar xzvf v2ray-plugin-linux-amd64-v${V2RAY_PLUGIN_VERSION}.tar.gz cp -f v2ray-plugin_linux_amd64 /usr/local/bin/v2ray-plugin From fd10d9ac2002dbf1eade75fd113b683893fc2201 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Fri, 12 Mar 2021 13:21:25 +0000 Subject: [PATCH 20/32] Force update repo key --- debian9-x86_64.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index 2d1af03..60966c2 100755 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -139,6 +139,10 @@ if [ "$REINSTALL" = "no" ] && [ "$CURRENT_OMR" = "$OMR_VERSION" ]; then exit 1 fi +[ -f /etc/apt/sources.list.d/openmptcprouter.list ] && { + echo "Update ${REPO} key" + wget -O - https://${REPO}/openmptcprouter.gpg.key | apt-key add - +} echo "Remove lock and update packages list..." rm -f /var/lib/dpkg/lock From 5291876fe682ca6404944030cae2235c90016a26 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Fri, 12 Mar 2021 16:57:04 +0000 Subject: [PATCH 21/32] Fix mlvpn source install and use binary by default --- debian9-x86_64.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index 60966c2..0a3520b 100755 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -28,7 +28,7 @@ UBOND_PASS=${UBOND_PASS:-$(head -c 32 /dev/urandom | base64 -w0)} OPENVPN=${OPENVPN:-yes} DSVPN=${DSVPN:-yes} WIREGUARD=${WIREGUARD:-yes} -SOURCES=${SOURCES:-yes} +SOURCES=${SOURCES:-no} NOINTERNET=${NOINTERNET:-no} REINSTALL=${REINSTALL:-yes} SPEEDTEST=${SPEEDTEST:-no} @@ -657,6 +657,7 @@ if [ "$MLVPN" = "yes" ]; then if [ -f /etc/mlvpn/mlvpn0.conf ]; then mlvpnupdate="1" fi + mkdir -p /etc/mlvpn if [ "$SOURCES" = "yes" ]; then rm -f /var/lib/dpkg/lock rm -f /var/lib/dpkg/lock-frontend @@ -691,7 +692,6 @@ if [ "$MLVPN" = "yes" ]; then else apt-get -y -o Dpkg::Options::="--force-overwrite" install omr-mlvpn=${MLVPN_BINARY_VERSION} fi - mkdir -p /etc/mlvpn if [ "$mlvpnupdate" = "0" ]; then sed -i "s:MLVPN_PASS:$MLVPN_PASS:" /etc/mlvpn/mlvpn0.conf fi From 69df502cb9eff01699e1a037b568689da3613086 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Fri, 12 Mar 2021 17:13:56 +0000 Subject: [PATCH 22/32] Keep old config --- debian9-x86_64.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index 0a3520b..136053e 100755 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -330,7 +330,7 @@ if [ "$SOURCES" = "yes" ]; then #rm -rf /tmp/shadowsocks-libev-${SHADOWSOCKS_VERSION} rm -rf /tmp/shadowsocks-libev else - apt-get -y -o Dpkg::Options::="--force-overwrite" install omr-shadowsocks-libev=${SHADOWSOCKS_BINARY_VERSION} + apt-get -y -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-overwrite" install omr-shadowsocks-libev=${SHADOWSOCKS_BINARY_VERSION} fi # Load OLIA Congestion module at boot time @@ -460,7 +460,7 @@ if [ "$OMR_ADMIN" = "yes" ]; then OMR_ADMIN_PASS_ADMIN2=$(cat /etc/openmptcprouter-vps-admin/omr-admin-config.json | jq -r .users[0].admin.user_password | tr -d "\n") [ -n "$OMR_ADMIN_PASS_ADMIN2" ] && [ "$OMR_ADMIN_PASS_ADMIN2" != "AdminMySecretKey" ] && OMR_ADMIN_PASS_ADMIN=$OMR_ADMIN_PASS_ADMIN2 fi - apt-get -y install omr-vps-admin=${OMR_ADMIN_BINARY_VERSION} + apt-get -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-overwrite" -y install omr-vps-admin=${OMR_ADMIN_BINARY_VERSION} if [ ! -f /etc/openmptcprouter-vps-admin/omr-admin-config.json ]; then cp /usr/share/omr-admin/omr-admin-config.json /etc/openmptcprouter-vps-admin/ fi @@ -624,7 +624,7 @@ if [ "$V2RAY" = "yes" ]; then dpkg --force-all -i -B /tmp/v2ray-${V2RAY_VERSION}-amd64.deb rm -f /tmp/v2ray-${V2RAY_VERSION}-amd64.deb else - apt-get -y install v2ray=${V2RAY_VERSION} + apt-get -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-overwrite" -y install v2ray=${V2RAY_VERSION} fi if [ -f /etc/v2ray/v2ray-server.conf ] && [ ! -f /etc/systemd/system/v2ray.service ]; then wget -O /etc/systemd/system/v2ray.service ${VPSURL}${VPSPATH}/old-v2ray.service @@ -690,7 +690,7 @@ if [ "$MLVPN" = "yes" ]; then fi fi else - apt-get -y -o Dpkg::Options::="--force-overwrite" install omr-mlvpn=${MLVPN_BINARY_VERSION} + apt-get -y -o Dpkg::Options::="--force-confold" -o Dpkg::Options::="--force-confdef" install omr-mlvpn=${MLVPN_BINARY_VERSION} fi if [ "$mlvpnupdate" = "0" ]; then sed -i "s:MLVPN_PASS:$MLVPN_PASS:" /etc/mlvpn/mlvpn0.conf From 507f49413cd3a7bdefe45a9d122e3b3f2d97d67a Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Mon, 15 Mar 2021 19:12:01 +0000 Subject: [PATCH 23/32] Update API --- debian9-x86_64.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index 136053e..90a710b 100755 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2018-2020 Ycarus (Yannick Chabanois) for OpenMPTCProuter +# Copyright (C) 2018-2021 Ycarus (Yannick Chabanois) for OpenMPTCProuter # # This is free software, licensed under the GNU General Public License v3 or later. # See /LICENSE for more information. @@ -46,8 +46,8 @@ MLVPN_BINARY_VERSION="3.0.0+20201216.git.2263bab" UBOND_VERSION="672100fb57913ffd29caad63517e145a5974b078" OBFS_VERSION="486bebd9208539058e57e23a12f23103016e09b4" OBFS_BINARY_VERSION="0.0.5-1" -OMR_ADMIN_VERSION="2e752ad783ffb817f6d627a999d51ac6656411f9" -OMR_ADMIN_BINARY_VERSION="0.3+20210304" +OMR_ADMIN_VERSION="f408dfb7e73970d3ae10bb188174c070e5b18fe7" +OMR_ADMIN_BINARY_VERSION="0.3+20210315" DSVPN_VERSION="3b99d2ef6c02b2ef68b5784bec8adfdd55b29b1a" DSVPN_BINARY_VERSION="0.1.4-2" V2RAY_VERSION="4.35.1" From 454046f830402050b6c7143eac494520ec4b46f1 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Mon, 15 Mar 2021 19:40:17 +0000 Subject: [PATCH 24/32] Update API --- debian9-x86_64.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index 90a710b..540473f 100755 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -46,7 +46,7 @@ MLVPN_BINARY_VERSION="3.0.0+20201216.git.2263bab" UBOND_VERSION="672100fb57913ffd29caad63517e145a5974b078" OBFS_VERSION="486bebd9208539058e57e23a12f23103016e09b4" OBFS_BINARY_VERSION="0.0.5-1" -OMR_ADMIN_VERSION="f408dfb7e73970d3ae10bb188174c070e5b18fe7" +OMR_ADMIN_VERSION="db77dc0508bf14089a185cbf3b2c1aee5333b2d7" OMR_ADMIN_BINARY_VERSION="0.3+20210315" DSVPN_VERSION="3b99d2ef6c02b2ef68b5784bec8adfdd55b29b1a" DSVPN_BINARY_VERSION="0.1.4-2" From 9a764d0eaf95b27a750e6a910e6531e9345ad9a8 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 23 Mar 2021 12:36:53 +0000 Subject: [PATCH 25/32] Fix LAN default route, fix https://github.com/Ysurac/openmptcprouter-vps/pull/47 in an other way --- omr-service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omr-service b/omr-service index 4b8e54d..0711abc 100755 --- a/omr-service +++ b/omr-service @@ -52,7 +52,7 @@ _lan_route() { while IFS=$"\n" read -r c; do vpnremoteip=$(echo "$c" | jq -r '.vpnremoteip') if [ -n "$vpnremoteip" ] && [ "$vpnremoteip" != "null" ]; then - echo "$c" | jq -c '.lanips //empty' | + echo "$c" | jq -c '.lanips[] //empty' | while IFS=$"\n" read -r d; do network=$(ipcalc -n $d | grep Network | awk '{print $2}') [ -n "$network" ] && [ -z "$(ip r show $network via $vpnremoteip)" ] && ip r replace $network via $vpnremoteip 2>&1 >/dev/null From 98ee07f6a6cd7e8bc7f4559788b018b9e641747a Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 23 Mar 2021 19:41:26 +0000 Subject: [PATCH 26/32] Add a test for a China compatible script --- debian9-x86_64.sh | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index 540473f..8cf27d3 100755 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -60,6 +60,7 @@ VPS_DOMAIN=${VPS_DOMAIN:-$(wget -4 -qO- -T 2 http://hostname.openmptcprouter.com VPSPATH="server-test" VPSURL="https://www.openmptcprouter.com/" REPO="repo.openmptcprouter.com" +CHINA=${CHINA:-no} OMR_VERSION="0.1025-test" @@ -176,16 +177,45 @@ if [ "$ID" = "ubuntu" ] && [ "$VERSION_ID" = "18.04" ] && [ "$UPDATE_OS" = "yes" apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" dist-upgrade VERSION_ID="20.04" fi + # Add OpenMPTCProuter repo echo "Add OpenMPTCProuter repo..." -echo "deb [arch=amd64] https://${REPO} buster main" > /etc/apt/sources.list.d/openmptcprouter.list -cat < /etc/apt/sources.list.d/openmptcprouter.list + cat /var/lib/openmptcprouter-vps-debian | apt-key add - + if [ ! -d /usr/share/omr-server ]; then + git clone https://gitee.com/ysurac/openmptcprouter-vps.git /usr/share/omr-server + fi + cd /usr/share/omr-server + git pull + if [ "$VPS_PATH" = "server-test" ]; then + git checkout develop + else + git checkout master + fi + DIR="/usr/share/omr-server" +else + echo "deb [arch=amd64] https://${REPO} buster main" > /etc/apt/sources.list.d/openmptcprouter.list + cat <<-EOF | tee /etc/apt/preferences.d/openmptcprouter.pref + Explanation: Prefer OpenMPTCProuter provided packages over the Debian native ones + Package: * + Pin: origin ${REPO} + Pin-Priority: 1001 + EOF + wget -O - https://${REPO}/openmptcprouter.gpg.key | apt-key add - +fi #apt-key adv --keyserver hkp://keys.gnupg.net --recv-keys 379CE192D401AB61 if [ "$ID" = "debian" ]; then From dae3133a1d308601b718b59911e2c052f185cd7f Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 23 Mar 2021 19:44:43 +0000 Subject: [PATCH 27/32] Fix --- debian9-x86_64.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index 8cf27d3..c8722ba 100755 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -194,7 +194,7 @@ if [ "$CHINA" = "yes" ]; then # git checkout main # fi echo "deb [arch=amd64] file:/var/lib/openmptcprouter-vps-debian ./" > /etc/apt/sources.list.d/openmptcprouter.list - cat /var/lib/openmptcprouter-vps-debian | apt-key add - + cat /var/lib/openmptcprouter-vps-debian/openmptcprouter.gpg.key | apt-key add - if [ ! -d /usr/share/omr-server ]; then git clone https://gitee.com/ysurac/openmptcprouter-vps.git /usr/share/omr-server fi From 31d4712c8314283508475a4f0fb0b4cb11145c9e Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 23 Mar 2021 19:49:12 +0000 Subject: [PATCH 28/32] Fix --- debian9-x86_64.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index c8722ba..bd715f1 100755 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -142,7 +142,11 @@ fi [ -f /etc/apt/sources.list.d/openmptcprouter.list ] && { echo "Update ${REPO} key" - wget -O - https://${REPO}/openmptcprouter.gpg.key | apt-key add - + if [ "$CHINA" = "yes" ]; then + wget -O - https://gitee.com/ysurac/openmptcprouter-vps-debian/raw/main/openmptcprouter.gpg.key | apt-key add - + else + wget -O - https://${REPO}/openmptcprouter.gpg.key | apt-key add - + fi } echo "Remove lock and update packages list..." @@ -195,17 +199,17 @@ if [ "$CHINA" = "yes" ]; then # fi echo "deb [arch=amd64] file:/var/lib/openmptcprouter-vps-debian ./" > /etc/apt/sources.list.d/openmptcprouter.list cat /var/lib/openmptcprouter-vps-debian/openmptcprouter.gpg.key | apt-key add - - if [ ! -d /usr/share/omr-server ]; then - git clone https://gitee.com/ysurac/openmptcprouter-vps.git /usr/share/omr-server + if [ ! -d /usr/share/omr-server-git ]; then + git clone https://gitee.com/ysurac/openmptcprouter-vps.git /usr/share/omr-server-git fi - cd /usr/share/omr-server + cd /usr/share/omr-server-git git pull if [ "$VPS_PATH" = "server-test" ]; then git checkout develop else git checkout master fi - DIR="/usr/share/omr-server" + DIR="/usr/share/omr-server-git" else echo "deb [arch=amd64] https://${REPO} buster main" > /etc/apt/sources.list.d/openmptcprouter.list cat <<-EOF | tee /etc/apt/preferences.d/openmptcprouter.pref From cedb65670e46ea680bddb3304e2f842569251be4 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 23 Mar 2021 19:53:25 +0000 Subject: [PATCH 29/32] Add missing files and use localfiles for china --- debian9-x86_64.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index bd715f1..6045365 100755 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -209,6 +209,7 @@ if [ "$CHINA" = "yes" ]; then else git checkout master fi + LOCALFILES="yes" DIR="/usr/share/omr-server-git" else echo "deb [arch=amd64] https://${REPO} buster main" > /etc/apt/sources.list.d/openmptcprouter.list From 07e23b78512794d7902387fe92151e4ee0488cca Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 23 Mar 2021 19:57:16 +0000 Subject: [PATCH 30/32] fix --- debian9-x86_64.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian9-x86_64.sh b/debian9-x86_64.sh index 6045365..a9c2151 100755 --- a/debian9-x86_64.sh +++ b/debian9-x86_64.sh @@ -192,7 +192,7 @@ if [ "$CHINA" = "yes" ]; then fi cd /var/lib/openmptcprouter-vps-debian git pull -# if [ "$VPS_PATH" = "server-test" ]; then +# if [ "$VPSPATH" = "server-test" ]; then # git checkout develop # else # git checkout main @@ -204,7 +204,7 @@ if [ "$CHINA" = "yes" ]; then fi cd /usr/share/omr-server-git git pull - if [ "$VPS_PATH" = "server-test" ]; then + if [ "$VPSPATH" = "server-test" ]; then git checkout develop else git checkout master From 1d2887c747f7fc3d0c3aa8a2fd5cfa77c0d226dc Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Tue, 23 Mar 2021 19:58:37 +0000 Subject: [PATCH 31/32] Add omr-test-speed --- omr-test-speed | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 omr-test-speed diff --git a/omr-test-speed b/omr-test-speed new file mode 100755 index 0000000..fa95ff2 --- /dev/null +++ b/omr-test-speed @@ -0,0 +1,42 @@ +#!/bin/sh +# vim: set noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 : +INTERFACE="$1" + +echo "Select best test server..." +HOSTLST="http://speedtest.frankfurt.linode.com/garbage.php?ckSize=10000 http://speedtest.tokyo2.linode.com/garbage.php?ckSize=10000 http://speedtest.singapore.linode.com/garbage.php?ckSize=10000 http://speedtest.newark.linode.com/garbage.php?ckSize=10000 http://speedtest.atlanta.linode.com/garbage.php?ckSize=10000 http://speedtest.dallas.linode.com/garbage.php?ckSize=10000 http://speedtest.fremont.linode.com/garbage.php?ckSize=10000 http://speedtest.tele2.net/1000GB.zip http://www.ovh.net/files/10Gb.dat https://speed.hetzner.de/10GB.bin http://ipv4.bouygues.testdebit.info/10G.iso http://par.download.datapacket.com/10000mb.bin http://nyc.download.datapacket.com/10000mb.bin http://ams.download.datapacket.com/10000mb.bin http://fra.download.datapacket.com/10000mb.bin http://lon.download.datapacket.com/10000mb.bin http://mad.download.datapacket.com/10000mb.bin http://prg.download.datapacket.com/10000mb.bin http://sto.download.datapacket.com/10000mb.bin http://vie.download.datapacket.com/10000mb.bin http://war.download.datapacket.com/10000mb.bin http://atl.download.datapacket.com/10000mb.bin http://chi.download.datapacket.com/10000mb.bin http://lax.download.datapacket.com/10000mb.bin http://mia.download.datapacket.com/10000mb.bin http://nyc.download.datapacket.com/10000mb.bin" +bestping="999" +for pinghost in $HOSTLST; do + domain=$(echo $pinghost | awk -F/ '{print $3}') + if [ -z "$INTERFACE" ]; then + ping=$(ping -c1 -w2 $domain | cut -d "/" -s -f5 | cut -d "." -f1) + else + ping=$(ping -c1 -w2 -I $INTERFACE -B $domain | cut -d "/" -s -f5 | cut -d "." -f1) + fi + echo "host: $domain - ping: $ping" + if [ -n "$ping" ] && [ "$ping" -lt "$bestping" ]; then + bestping=$ping + HOST=$pinghost + fi +done + +[ -z "$HOST" ] && HOST="http://proof.ovh.net/files/10Gio.dat" + +echo "Best server is $HOST, running test:" +trap : HUP INT TERM +if [ -z "$INTERFACE" ]; then + curl -4 $HOST >/dev/null || echo +else + domain=$(echo $HOST | awk -F/ '{print $3}') + hostip=$(dig +nocmd +noall +answer A $domain | grep -v CNAME | awk '{print $5}' | tr '\n' ' ') + if [ -n "$(ipset list 2>/dev/null | grep ss_rules)" ]; then + for ip in $hostip; do + ipset add ss_rules_dst_bypass_all $ip + done + fi + curl -4 --interface $INTERFACE $HOST >/dev/null || echo + if [ -n "$(ipset list 2>/dev/null | grep ss_rules)" ]; then + for ip in $hostip; do + ipset del ss_rules_dst_bypass_all $ip + done + fi +fi From 5023d5cf33a4381d85e0b2d804c552a1591f2834 Mon Sep 17 00:00:00 2001 From: "Ycarus (Yannick Chabanois)" Date: Wed, 24 Mar 2021 14:02:18 +0000 Subject: [PATCH 32/32] Fix --- omr-service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omr-service b/omr-service index 0711abc..6fe97bf 100755 --- a/omr-service +++ b/omr-service @@ -52,7 +52,7 @@ _lan_route() { while IFS=$"\n" read -r c; do vpnremoteip=$(echo "$c" | jq -r '.vpnremoteip') if [ -n "$vpnremoteip" ] && [ "$vpnremoteip" != "null" ]; then - echo "$c" | jq -c '.lanips[] //empty' | + echo "$c" | jq -c -r '.lanips[] //empty' | while IFS=$"\n" read -r d; do network=$(ipcalc -n $d | grep Network | awk '{print $2}') [ -n "$network" ] && [ -z "$(ip r show $network via $vpnremoteip)" ] && ip r replace $network via $vpnremoteip 2>&1 >/dev/null