mirror of
https://github.com/Ysurac/openmptcprouter-vps.git
synced 2025-03-09 15:50:00 +00:00
Update to latest VPS script version
This commit is contained in:
parent
8f3d071b2a
commit
0a808c59b2
4 changed files with 71 additions and 45 deletions
|
@ -10,17 +10,17 @@ MLVPN=${MLVPN:-no}
|
||||||
MLVPN_PASS=${MLVPN_PASS:-$(head -c 32 /dev/urandom | base64 -w0)}
|
MLVPN_PASS=${MLVPN_PASS:-$(head -c 32 /dev/urandom | base64 -w0)}
|
||||||
OPENVPN=${OPENVPN:-no}
|
OPENVPN=${OPENVPN:-no}
|
||||||
INTERFACE=${INTERFACE:-$(ip -o -4 route show to default | grep -Po '(?<=dev )(\S+)' | tr -d "\n")}
|
INTERFACE=${INTERFACE:-$(ip -o -4 route show to default | grep -Po '(?<=dev )(\S+)' | tr -d "\n")}
|
||||||
KERNEL_VERSION="4.14.79-mptcp-6ece8f4"
|
KERNEL_VERSION="4.14.89-mptcp-a9f6d31"
|
||||||
GLORYTUN_UDP_VERSION="8ff9d3d7a1481bd82578d98798360cf219f3b73a"
|
GLORYTUN_UDP_VERSION="067ddd4aa04dbb628463666a90b7dcf3cd6963c9"
|
||||||
MLVPN_VERSION="8f9720978b28c1954f9f229525333547283316d2"
|
MLVPN_VERSION="8f9720978b28c1954f9f229525333547283316d2"
|
||||||
OBFS_VERSION="7659eeccf473aa41eb294e92c32f8f60a8747325"
|
OBFS_VERSION="7659eeccf473aa41eb294e92c32f8f60a8747325"
|
||||||
SHADOWSOCKS_VERSION="3.2.3"
|
SHADOWSOCKS_VERSION="3.2.3"
|
||||||
OMR_VERSION="0.70"
|
OMR_VERSION="0.83"
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
umask 0022
|
umask 0022
|
||||||
|
|
||||||
rm -rf /var/lib/dpkg/lock
|
rm -f /var/lib/dpkg/lock
|
||||||
|
|
||||||
# Check Linux version
|
# Check Linux version
|
||||||
if test -f /etc/os-release ; then
|
if test -f /etc/os-release ; then
|
||||||
|
@ -43,6 +43,9 @@ fi
|
||||||
if [ -f /etc/motd ] && 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
|
sed -i 's/OpenMPCTProuter/OpenMPTCProuter/g' /etc/motd
|
||||||
fi
|
fi
|
||||||
|
if [ -f /etc/motd.head ] && grep --quiet 'OpenMPCTProuter VPS' /etc/motd.head ; then
|
||||||
|
sed -i 's/OpenMPCTProuter/OpenMPTCProuter/g' /etc/motd.head
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if OpenMPTCProuter VPS is already installed
|
# Check if OpenMPTCProuter VPS is already installed
|
||||||
update="0"
|
update="0"
|
||||||
|
@ -70,7 +73,7 @@ wget -O /tmp/linux-image-${KERNEL_VERSION}.amd64.deb https://www.openmptcprouter
|
||||||
wget -O /tmp/linux-headers-${KERNEL_VERSION}.amd64.deb https://www.openmptcprouter.com/kernel/linux-headers-${KERNEL_VERSION}.amd64.deb
|
wget -O /tmp/linux-headers-${KERNEL_VERSION}.amd64.deb https://www.openmptcprouter.com/kernel/linux-headers-${KERNEL_VERSION}.amd64.deb
|
||||||
# Rename bzImage to vmlinuz, needed when custom kernel was used
|
# Rename bzImage to vmlinuz, needed when custom kernel was used
|
||||||
cd /boot
|
cd /boot
|
||||||
apt-get -y install rename
|
apt-get -y install rename curl
|
||||||
rename 's/^bzImage/vmlinuz/s' * >/dev/null 2>&1
|
rename 's/^bzImage/vmlinuz/s' * >/dev/null 2>&1
|
||||||
#apt-get -y install linux-mptcp
|
#apt-get -y install linux-mptcp
|
||||||
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-image-${KERNEL_VERSION}.amd64.deb
|
||||||
|
@ -91,21 +94,25 @@ tar xzf shadowsocks-libev-${SHADOWSOCKS_VERSION}.tar.gz
|
||||||
cd shadowsocks-libev-${SHADOWSOCKS_VERSION}
|
cd shadowsocks-libev-${SHADOWSOCKS_VERSION}
|
||||||
wget https://raw.githubusercontent.com/Ysurac/openmptcprouter-feeds/master/shadowsocks-libev/patches/020-NOCRYPTO.patch
|
wget https://raw.githubusercontent.com/Ysurac/openmptcprouter-feeds/master/shadowsocks-libev/patches/020-NOCRYPTO.patch
|
||||||
patch -p1 < 020-NOCRYPTO.patch
|
patch -p1 < 020-NOCRYPTO.patch
|
||||||
apt-get -y install --no-install-recommends devscripts equivs apg libcap2-bin libpam-cap
|
rm -f /var/lib/dpkg/lock
|
||||||
apt-get -y install libc-ares2 libc-ares-dev libev4
|
apt-get -y install --no-install-recommends devscripts equivs apg libcap2-bin libpam-cap libc-ares2 libc-ares-dev libev4 haveged
|
||||||
# Install haveged entropy daemon
|
rm -f /var/lib/dpkg/lock
|
||||||
apt-get -y install haveged
|
|
||||||
systemctl enable haveged
|
systemctl enable haveged
|
||||||
|
|
||||||
if [ "$ID" = "debian" ]; then
|
if [ "$ID" = "debian" ]; then
|
||||||
|
rm -f /var/lib/dpkg/lock
|
||||||
apt -y -t stretch-backports install libsodium-dev
|
apt -y -t stretch-backports install libsodium-dev
|
||||||
elif [ "$ID" = "ubuntu" ]; then
|
elif [ "$ID" = "ubuntu" ]; then
|
||||||
|
rm -f /var/lib/dpkg/lock
|
||||||
apt-get -y install libsodium-dev
|
apt-get -y install libsodium-dev
|
||||||
systemctl enable haveged
|
systemctl enable haveged
|
||||||
fi
|
fi
|
||||||
|
rm -f /var/lib/dpkg/lock
|
||||||
mk-build-deps --install --tool "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y"
|
mk-build-deps --install --tool "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y"
|
||||||
|
rm -f /var/lib/dpkg/lock
|
||||||
dpkg-buildpackage -b -us -uc
|
dpkg-buildpackage -b -us -uc
|
||||||
cd ..
|
cd ..
|
||||||
|
rm -f /var/lib/dpkg/lock
|
||||||
dpkg -i shadowsocks-libev_${SHADOWSOCKS_VERSION}-1_amd64.deb
|
dpkg -i shadowsocks-libev_${SHADOWSOCKS_VERSION}-1_amd64.deb
|
||||||
rm -rf /tmp/shadowsocks-libev-${SHADOWSOCKS_VERSION}
|
rm -rf /tmp/shadowsocks-libev-${SHADOWSOCKS_VERSION}
|
||||||
|
|
||||||
|
@ -181,7 +188,8 @@ if [ "$OBFS" = "yes" ]; then
|
||||||
echo "Install OBFS"
|
echo "Install OBFS"
|
||||||
rm -rf /tmp/simple-obfs
|
rm -rf /tmp/simple-obfs
|
||||||
cd /tmp
|
cd /tmp
|
||||||
sudo apt-get install -y --no-install-recommends build-essential autoconf libtool libssl-dev libpcre3-dev libev-dev asciidoc xmlto automake git ca-certificates
|
rm -f /var/lib/dpkg/lock
|
||||||
|
apt-get install -y --no-install-recommends build-essential autoconf libtool libssl-dev libpcre3-dev libev-dev asciidoc xmlto automake git ca-certificates
|
||||||
git clone https://github.com/shadowsocks/simple-obfs.git /tmp/simple-obfs
|
git clone https://github.com/shadowsocks/simple-obfs.git /tmp/simple-obfs
|
||||||
cd /tmp/simple-obfs
|
cd /tmp/simple-obfs
|
||||||
git checkout ${OBFS_VERSION}
|
git checkout ${OBFS_VERSION}
|
||||||
|
@ -208,6 +216,7 @@ if [ "$MLVPN" = "yes" ]; then
|
||||||
if [ -f /etc/mlvpn/mlvpn0.conf ]; then
|
if [ -f /etc/mlvpn/mlvpn0.conf ]; then
|
||||||
mlvpnupdate="1"
|
mlvpnupdate="1"
|
||||||
fi
|
fi
|
||||||
|
rm -f /var/lib/dpkg/lock
|
||||||
apt-get -y install build-essential pkg-config autoconf automake libpcap-dev unzip git
|
apt-get -y install build-essential pkg-config autoconf automake libpcap-dev unzip git
|
||||||
rm -rf /tmp/mlvpn
|
rm -rf /tmp/mlvpn
|
||||||
cd /tmp
|
cd /tmp
|
||||||
|
@ -241,6 +250,7 @@ if systemctl -q is-active openvpn-server@tun0.service; then
|
||||||
fi
|
fi
|
||||||
if [ "$OPENVPN" = "yes" ]; then
|
if [ "$OPENVPN" = "yes" ]; then
|
||||||
echo "Install OpenVPN"
|
echo "Install OpenVPN"
|
||||||
|
rm -f /var/lib/dpkg/lock
|
||||||
apt-get -y install openvpn
|
apt-get -y install openvpn
|
||||||
wget -O /lib/systemd/network/openvpn.network https://www.openmptcprouter.com/server/openvpn.network
|
wget -O /lib/systemd/network/openvpn.network https://www.openmptcprouter.com/server/openvpn.network
|
||||||
if [ ! -f "/etc/openvpn/server/static.key" ]; then
|
if [ ! -f "/etc/openvpn/server/static.key" ]; then
|
||||||
|
@ -256,6 +266,7 @@ echo 'Glorytun UDP'
|
||||||
if systemctl -q is-active glorytun-udp@tun0.service; then
|
if systemctl -q is-active glorytun-udp@tun0.service; then
|
||||||
systemctl -q stop glorytun-udp@tun0 > /dev/null 2>&1
|
systemctl -q stop glorytun-udp@tun0 > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
rm -f /var/lib/dpkg/lock
|
||||||
apt-get install -y --no-install-recommends build-essential git ca-certificates meson pkg-config
|
apt-get install -y --no-install-recommends build-essential git ca-certificates meson pkg-config
|
||||||
rm -rf /tmp/glorytun-udp
|
rm -rf /tmp/glorytun-udp
|
||||||
cd /tmp
|
cd /tmp
|
||||||
|
@ -293,6 +304,7 @@ if [ "$ID" = "debian" ]; then
|
||||||
elif [ "$ID" = "ubuntu" ]; then
|
elif [ "$ID" = "ubuntu" ]; then
|
||||||
apt-get -y install libsodium-dev
|
apt-get -y install libsodium-dev
|
||||||
fi
|
fi
|
||||||
|
rm -f /var/lib/dpkg/lock
|
||||||
apt-get -y install build-essential pkg-config autoconf automake
|
apt-get -y install build-essential pkg-config autoconf automake
|
||||||
rm -rf /tmp/glorytun-0.0.35
|
rm -rf /tmp/glorytun-0.0.35
|
||||||
cd /tmp
|
cd /tmp
|
||||||
|
@ -369,6 +381,7 @@ else
|
||||||
wget -O /etc/shorewall/params.vpn https://www.openmptcprouter.com/server/shorewall4/params.vpn
|
wget -O /etc/shorewall/params.vpn https://www.openmptcprouter.com/server/shorewall4/params.vpn
|
||||||
wget -O /etc/shorewall/params.net https://www.openmptcprouter.com/server/shorewall4/params.net
|
wget -O /etc/shorewall/params.net https://www.openmptcprouter.com/server/shorewall4/params.net
|
||||||
sed -i "s:eth0:$INTERFACE:g" /etc/shorewall/*
|
sed -i "s:eth0:$INTERFACE:g" /etc/shorewall/*
|
||||||
|
sed -i 's/^.*#DNAT/#DNAT/g' /etc/shorewall/rules
|
||||||
sed -i 's:10.0.0.2:$OMR_ADDR:g' /etc/shorewall/rules
|
sed -i 's:10.0.0.2:$OMR_ADDR:g' /etc/shorewall/rules
|
||||||
wget -O /etc/shorewall6/params https://www.openmptcprouter.com/server/shorewall6/params
|
wget -O /etc/shorewall6/params https://www.openmptcprouter.com/server/shorewall6/params
|
||||||
wget -O /etc/shorewall6/params.net https://www.openmptcprouter.com/server/shorewall6/params.net
|
wget -O /etc/shorewall6/params.net https://www.openmptcprouter.com/server/shorewall6/params.net
|
||||||
|
@ -381,15 +394,15 @@ fi
|
||||||
# Add OpenMPTCProuter VPS script version to /etc/motd
|
# Add OpenMPTCProuter VPS script version to /etc/motd
|
||||||
if [ -f /etc/motd.head ]; then
|
if [ -f /etc/motd.head ]; then
|
||||||
if grep --quiet 'OpenMPTCProuter VPS' /etc/motd.head; then
|
if grep --quiet 'OpenMPTCProuter VPS' /etc/motd.head; then
|
||||||
sed -i "s:< OpenMPTCProuter VPS [0-9]*\.[0-9]* >:< OpenMPCTProuter VPS $OMR_VERSION >:" /etc/motd.head
|
sed -i "s:< OpenMPTCProuter VPS [0-9]*\.[0-9]* >:< OpenMPTCProuter VPS $OMR_VERSION >:g" /etc/motd.head
|
||||||
sed -i "s:< OpenMPTCProuter VPS \$OMR_VERSION >:< OpenMPCTProuter VPS $OMR_VERSION >:" /etc/motd.head
|
sed -i "s:< OpenMPTCProuter VPS \$OMR_VERSION >:< OpenMPTCProuter VPS $OMR_VERSION >:g" /etc/motd.head
|
||||||
else
|
else
|
||||||
echo "< OpenMPTCProuter VPS $OMR_VERSION >" >> /etc/motd.head
|
echo "< OpenMPTCProuter VPS $OMR_VERSION >" >> /etc/motd.head
|
||||||
fi
|
fi
|
||||||
elif [ -f /etc/motd ]; then
|
elif [ -f /etc/motd ]; then
|
||||||
if grep --quiet 'OpenMPTCProuter VPS' /etc/motd; then
|
if grep --quiet 'OpenMPTCProuter VPS' /etc/motd; then
|
||||||
sed -i "s:< OpenMPTCProuter VPS [0-9]*\.[0-9]* >:< OpenMPCTProuter VPS $OMR_VERSION >:" /etc/motd
|
sed -i "s:< OpenMPTCProuter VPS [0-9]*\.[0-9]* >:< OpenMPTCProuter VPS $OMR_VERSION >:g" /etc/motd
|
||||||
sed -i "s:< OpenMPTCProuter VPS \$OMR_VERSION >:< OpenMPCTProuter VPS $OMR_VERSION >:" /etc/motd
|
sed -i "s:< OpenMPTCProuter VPS \$OMR_VERSION >:< OpenMPTCProuter VPS $OMR_VERSION >:g" /etc/motd
|
||||||
else
|
else
|
||||||
echo "< OpenMPTCProuter VPS $OMR_VERSION >" >> /etc/motd
|
echo "< OpenMPTCProuter VPS $OMR_VERSION >" >> /etc/motd
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -9,7 +9,7 @@ IPMasquerade=yes
|
||||||
|
|
||||||
[DHCPServer]
|
[DHCPServer]
|
||||||
PoolOffset=2
|
PoolOffset=2
|
||||||
PoolSize=10
|
PoolSize=2
|
||||||
EmitDNS=no
|
EmitDNS=no
|
||||||
EmitNTP=no
|
EmitNTP=no
|
||||||
DNS=9.9.9.9
|
DNS=9.9.9.9
|
||||||
|
|
|
@ -12,7 +12,7 @@ IPMasquerade=yes
|
||||||
|
|
||||||
[DHCPServer]
|
[DHCPServer]
|
||||||
PoolOffset=1
|
PoolOffset=1
|
||||||
PoolSize=10
|
PoolSize=2
|
||||||
EmitDNS=no
|
EmitDNS=no
|
||||||
EmitNTP=no
|
EmitNTP=no
|
||||||
DNS=9.9.9.9
|
DNS=9.9.9.9
|
||||||
|
|
71
omr-service
71
omr-service
|
@ -9,15 +9,17 @@ if [ "$1" = "stop" ] && [ "$(ip link show omr-6in4 up 2>/dev/null)" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Force multipath status
|
_multipath() {
|
||||||
source /etc/shorewall/params.net
|
# Force multipath status
|
||||||
for intf in `ls -1 /sys/class/net`; do
|
source /etc/shorewall/params.net
|
||||||
if [ "$intf" = "$NET_IFACE" ]; then
|
for intf in `ls -1 /sys/class/net`; do
|
||||||
multipath $intf on
|
if [ "$intf" = "$NET_IFACE" ]; then
|
||||||
else
|
multipath $intf on
|
||||||
multipath $intf off
|
else
|
||||||
fi
|
multipath $intf off
|
||||||
done
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# Add IPv6 tunnel
|
# Add IPv6 tunnel
|
||||||
if [ "$(ip link show omr-6in4 up 2>/dev/null)" ]; then
|
if [ "$(ip link show omr-6in4 up 2>/dev/null)" ]; then
|
||||||
|
@ -43,7 +45,7 @@ _ping() {
|
||||||
|
|
||||||
_ping_range() {
|
_ping_range() {
|
||||||
local network=$1
|
local network=$1
|
||||||
for i in {2..10} ;do
|
for i in {2..50} ;do
|
||||||
_ping $network$i
|
_ping $network$i
|
||||||
pingr=$?
|
pingr=$?
|
||||||
if $(exit $pingr); then
|
if $(exit $pingr); then
|
||||||
|
@ -65,35 +67,46 @@ while true; do
|
||||||
if ! $(exit $status) || [ "$currentpeer" != "$OMR_ADDR" ]; then
|
if ! $(exit $status) || [ "$currentpeer" != "$OMR_ADDR" ]; then
|
||||||
allip_tcp=$(ip -4 addr show gt-tun0 2>/dev/null | grep inet)
|
allip_tcp=$(ip -4 addr show gt-tun0 2>/dev/null | grep inet)
|
||||||
allip_udp=$(ip -4 addr show gt-udp-tun0 2>/dev/null | grep inet)
|
allip_udp=$(ip -4 addr show gt-udp-tun0 2>/dev/null | grep inet)
|
||||||
allip_mlvpn=$(ip -4 addr show mlvpn0 2>/dev/null | grep inet)
|
[ -d "/sys/class/net/mlvpn0" ] && allip_mlvpn=$(ip -4 addr show mlvpn0 2>/dev/null | grep inet)
|
||||||
allip_openvpn=$(ip -4 addr show tun0 2>/dev/null | grep inet)
|
[ -d "/sys/class/net/tun0" ] && allip_openvpn=$(ip -4 addr show tun0 2>/dev/null | grep inet)
|
||||||
allip="$allip_tcp
|
allip="$allip_tcp
|
||||||
$allip_udp
|
$allip_udp
|
||||||
$allip_openvpn
|
$allip_openvpn
|
||||||
$allip_mlvpn"
|
$allip_mlvpn"
|
||||||
while IFS= read -r inet; do
|
while IFS= read -r inet; do
|
||||||
ip=$(echo $inet | awk '{print $2}' | cut -d/ -f1 | tr -d "\n")
|
ip=$(echo $inet | awk '{print $2}' | cut -d/ -f1 | tr -d "\n")
|
||||||
_ping_range $(echo $ip | sed 's/.1/./' | tr -d "\n")
|
if [ "$ip" != "" ]; then
|
||||||
statusr=$?
|
_ping_range $(echo $ip | sed 's/.1/./' | tr -d "\n")
|
||||||
if $(exit $statusr); then
|
statusr=$?
|
||||||
_ping $ipd
|
if $(exit $statusr); then
|
||||||
statusp=$?
|
_ping $ipd
|
||||||
if $(exit $statusp); then
|
statusp=$?
|
||||||
ip tunnel change omr-6in4 mode sit remote $ipd local $ip
|
if $(exit $statusp); then
|
||||||
echo "VPS_ADDR=$ip" > /etc/shorewall/params.vpn
|
ip tunnel change omr-6in4 mode sit remote $ipd local $ip
|
||||||
echo "OMR_ADDR=$ipd" >> /etc/shorewall/params.vpn
|
echo "VPS_ADDR=$ip" > /etc/shorewall/params.vpn
|
||||||
iface=$(ip -4 addr | grep $ip | awk '{print $7}' | tr -d "\n")
|
echo "OMR_ADDR=$ipd" >> /etc/shorewall/params.vpn
|
||||||
echo "VPS_IFACE=$iface" >> /etc/shorewall/params.vpn
|
iface=$(ip -4 addr | grep $ip | awk '{print $7}' | tr -d "\n")
|
||||||
systemctl reload shorewall
|
echo "VPS_IFACE=$iface" >> /etc/shorewall/params.vpn
|
||||||
break
|
systemctl reload shorewall
|
||||||
|
_multipath
|
||||||
|
break
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done < <(printf '%s\n' "$allip")
|
done < <(printf '%s\n' "$allip")
|
||||||
#[ -z "$iface" ] && {
|
[ -z "$iface" ] && {
|
||||||
# systemctl -q restart systemd-networkd
|
systemctl -q restart glorytun-tcp@tun0
|
||||||
# sleep 10
|
systemctl -q restart glorytun-udp@tun0
|
||||||
#}
|
systemctl -q restart systemd-networkd
|
||||||
|
_multipath
|
||||||
|
sleep 10
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
result="$(curl -Isk https://127.0.0.1:65500/status | head -n 1 | grep 401)"
|
||||||
|
if [ "$result" = "" ]; then
|
||||||
|
systemctl -q restart omr-admin
|
||||||
|
sleep 10
|
||||||
|
fi
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue