mirror of
https://github.com/Ysurac/openmptcprouter-vps.git
synced 2025-02-12 11:21:56 +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)}
|
||||
OPENVPN=${OPENVPN:-no}
|
||||
INTERFACE=${INTERFACE:-$(ip -o -4 route show to default | grep -Po '(?<=dev )(\S+)' | tr -d "\n")}
|
||||
KERNEL_VERSION="4.14.79-mptcp-6ece8f4"
|
||||
GLORYTUN_UDP_VERSION="8ff9d3d7a1481bd82578d98798360cf219f3b73a"
|
||||
KERNEL_VERSION="4.14.89-mptcp-a9f6d31"
|
||||
GLORYTUN_UDP_VERSION="067ddd4aa04dbb628463666a90b7dcf3cd6963c9"
|
||||
MLVPN_VERSION="8f9720978b28c1954f9f229525333547283316d2"
|
||||
OBFS_VERSION="7659eeccf473aa41eb294e92c32f8f60a8747325"
|
||||
SHADOWSOCKS_VERSION="3.2.3"
|
||||
OMR_VERSION="0.70"
|
||||
OMR_VERSION="0.83"
|
||||
|
||||
set -e
|
||||
umask 0022
|
||||
|
||||
rm -rf /var/lib/dpkg/lock
|
||||
rm -f /var/lib/dpkg/lock
|
||||
|
||||
# Check Linux version
|
||||
if test -f /etc/os-release ; then
|
||||
|
@ -43,6 +43,9 @@ fi
|
|||
if [ -f /etc/motd ] && grep --quiet 'OpenMPCTProuter VPS' /etc/motd ; then
|
||||
sed -i 's/OpenMPCTProuter/OpenMPTCProuter/g' /etc/motd
|
||||
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
|
||||
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
|
||||
# Rename bzImage to vmlinuz, needed when custom kernel was used
|
||||
cd /boot
|
||||
apt-get -y install rename
|
||||
apt-get -y install rename curl
|
||||
rename 's/^bzImage/vmlinuz/s' * >/dev/null 2>&1
|
||||
#apt-get -y install linux-mptcp
|
||||
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}
|
||||
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
|
||||
# Install haveged entropy daemon
|
||||
apt-get -y install haveged
|
||||
rm -f /var/lib/dpkg/lock
|
||||
apt-get -y install --no-install-recommends devscripts equivs apg libcap2-bin libpam-cap libc-ares2 libc-ares-dev libev4 haveged
|
||||
rm -f /var/lib/dpkg/lock
|
||||
systemctl enable haveged
|
||||
|
||||
if [ "$ID" = "debian" ]; then
|
||||
rm -f /var/lib/dpkg/lock
|
||||
apt -y -t stretch-backports install libsodium-dev
|
||||
elif [ "$ID" = "ubuntu" ]; then
|
||||
rm -f /var/lib/dpkg/lock
|
||||
apt-get -y install libsodium-dev
|
||||
systemctl enable haveged
|
||||
fi
|
||||
rm -f /var/lib/dpkg/lock
|
||||
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
|
||||
cd ..
|
||||
rm -f /var/lib/dpkg/lock
|
||||
dpkg -i shadowsocks-libev_${SHADOWSOCKS_VERSION}-1_amd64.deb
|
||||
rm -rf /tmp/shadowsocks-libev-${SHADOWSOCKS_VERSION}
|
||||
|
||||
|
@ -181,7 +188,8 @@ if [ "$OBFS" = "yes" ]; then
|
|||
echo "Install OBFS"
|
||||
rm -rf /tmp/simple-obfs
|
||||
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
|
||||
cd /tmp/simple-obfs
|
||||
git checkout ${OBFS_VERSION}
|
||||
|
@ -208,6 +216,7 @@ if [ "$MLVPN" = "yes" ]; then
|
|||
if [ -f /etc/mlvpn/mlvpn0.conf ]; then
|
||||
mlvpnupdate="1"
|
||||
fi
|
||||
rm -f /var/lib/dpkg/lock
|
||||
apt-get -y install build-essential pkg-config autoconf automake libpcap-dev unzip git
|
||||
rm -rf /tmp/mlvpn
|
||||
cd /tmp
|
||||
|
@ -241,6 +250,7 @@ if systemctl -q is-active openvpn-server@tun0.service; then
|
|||
fi
|
||||
if [ "$OPENVPN" = "yes" ]; then
|
||||
echo "Install OpenVPN"
|
||||
rm -f /var/lib/dpkg/lock
|
||||
apt-get -y install openvpn
|
||||
wget -O /lib/systemd/network/openvpn.network https://www.openmptcprouter.com/server/openvpn.network
|
||||
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
|
||||
systemctl -q stop glorytun-udp@tun0 > /dev/null 2>&1
|
||||
fi
|
||||
rm -f /var/lib/dpkg/lock
|
||||
apt-get install -y --no-install-recommends build-essential git ca-certificates meson pkg-config
|
||||
rm -rf /tmp/glorytun-udp
|
||||
cd /tmp
|
||||
|
@ -293,6 +304,7 @@ if [ "$ID" = "debian" ]; then
|
|||
elif [ "$ID" = "ubuntu" ]; then
|
||||
apt-get -y install libsodium-dev
|
||||
fi
|
||||
rm -f /var/lib/dpkg/lock
|
||||
apt-get -y install build-essential pkg-config autoconf automake
|
||||
rm -rf /tmp/glorytun-0.0.35
|
||||
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.net https://www.openmptcprouter.com/server/shorewall4/params.net
|
||||
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
|
||||
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
|
||||
|
@ -381,15 +394,15 @@ fi
|
|||
# Add OpenMPTCProuter VPS script version to /etc/motd
|
||||
if [ -f /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 \$OMR_VERSION >:< 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 >:< OpenMPTCProuter VPS $OMR_VERSION >:g" /etc/motd.head
|
||||
else
|
||||
echo "< OpenMPTCProuter VPS $OMR_VERSION >" >> /etc/motd.head
|
||||
fi
|
||||
elif [ -f /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 \$OMR_VERSION >:< 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 >:< OpenMPTCProuter VPS $OMR_VERSION >:g" /etc/motd
|
||||
else
|
||||
echo "< OpenMPTCProuter VPS $OMR_VERSION >" >> /etc/motd
|
||||
fi
|
||||
|
|
|
@ -9,7 +9,7 @@ IPMasquerade=yes
|
|||
|
||||
[DHCPServer]
|
||||
PoolOffset=2
|
||||
PoolSize=10
|
||||
PoolSize=2
|
||||
EmitDNS=no
|
||||
EmitNTP=no
|
||||
DNS=9.9.9.9
|
||||
|
|
|
@ -12,7 +12,7 @@ IPMasquerade=yes
|
|||
|
||||
[DHCPServer]
|
||||
PoolOffset=1
|
||||
PoolSize=10
|
||||
PoolSize=2
|
||||
EmitDNS=no
|
||||
EmitNTP=no
|
||||
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
|
||||
fi
|
||||
|
||||
# Force multipath status
|
||||
source /etc/shorewall/params.net
|
||||
for intf in `ls -1 /sys/class/net`; do
|
||||
if [ "$intf" = "$NET_IFACE" ]; then
|
||||
multipath $intf on
|
||||
else
|
||||
multipath $intf off
|
||||
fi
|
||||
done
|
||||
_multipath() {
|
||||
# Force multipath status
|
||||
source /etc/shorewall/params.net
|
||||
for intf in `ls -1 /sys/class/net`; do
|
||||
if [ "$intf" = "$NET_IFACE" ]; then
|
||||
multipath $intf on
|
||||
else
|
||||
multipath $intf off
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Add IPv6 tunnel
|
||||
if [ "$(ip link show omr-6in4 up 2>/dev/null)" ]; then
|
||||
|
@ -43,7 +45,7 @@ _ping() {
|
|||
|
||||
_ping_range() {
|
||||
local network=$1
|
||||
for i in {2..10} ;do
|
||||
for i in {2..50} ;do
|
||||
_ping $network$i
|
||||
pingr=$?
|
||||
if $(exit $pingr); then
|
||||
|
@ -65,35 +67,46 @@ while true; do
|
|||
if ! $(exit $status) || [ "$currentpeer" != "$OMR_ADDR" ]; then
|
||||
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_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/mlvpn0" ] && allip_mlvpn=$(ip -4 addr show mlvpn0 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_udp
|
||||
$allip_openvpn
|
||||
$allip_mlvpn"
|
||||
while IFS= read -r inet; do
|
||||
ip=$(echo $inet | awk '{print $2}' | cut -d/ -f1 | tr -d "\n")
|
||||
_ping_range $(echo $ip | sed 's/.1/./' | tr -d "\n")
|
||||
statusr=$?
|
||||
if $(exit $statusr); then
|
||||
_ping $ipd
|
||||
statusp=$?
|
||||
if $(exit $statusp); then
|
||||
ip tunnel change omr-6in4 mode sit remote $ipd local $ip
|
||||
echo "VPS_ADDR=$ip" > /etc/shorewall/params.vpn
|
||||
echo "OMR_ADDR=$ipd" >> /etc/shorewall/params.vpn
|
||||
iface=$(ip -4 addr | grep $ip | awk '{print $7}' | tr -d "\n")
|
||||
echo "VPS_IFACE=$iface" >> /etc/shorewall/params.vpn
|
||||
systemctl reload shorewall
|
||||
break
|
||||
if [ "$ip" != "" ]; then
|
||||
_ping_range $(echo $ip | sed 's/.1/./' | tr -d "\n")
|
||||
statusr=$?
|
||||
if $(exit $statusr); then
|
||||
_ping $ipd
|
||||
statusp=$?
|
||||
if $(exit $statusp); then
|
||||
ip tunnel change omr-6in4 mode sit remote $ipd local $ip
|
||||
echo "VPS_ADDR=$ip" > /etc/shorewall/params.vpn
|
||||
echo "OMR_ADDR=$ipd" >> /etc/shorewall/params.vpn
|
||||
iface=$(ip -4 addr | grep $ip | awk '{print $7}' | tr -d "\n")
|
||||
echo "VPS_IFACE=$iface" >> /etc/shorewall/params.vpn
|
||||
systemctl reload shorewall
|
||||
_multipath
|
||||
break
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done < <(printf '%s\n' "$allip")
|
||||
#[ -z "$iface" ] && {
|
||||
# systemctl -q restart systemd-networkd
|
||||
# sleep 10
|
||||
#}
|
||||
[ -z "$iface" ] && {
|
||||
systemctl -q restart glorytun-tcp@tun0
|
||||
systemctl -q restart glorytun-udp@tun0
|
||||
systemctl -q restart systemd-networkd
|
||||
_multipath
|
||||
sleep 10
|
||||
}
|
||||
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
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue