mirror of
https://github.com/Ysurac/openmptcprouter-vps.git
synced 2025-03-09 15:50:00 +00:00
Add update part to script and enable omr-6in4
This commit is contained in:
parent
04c961d9ab
commit
b5d787b50c
1 changed files with 101 additions and 54 deletions
|
@ -9,7 +9,7 @@ DEBIAN_VERSION=$(sed 's/\..*//' /etc/debian_version)
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
umask 0022
|
umask 0022
|
||||||
|
update=0
|
||||||
if [ $DEBIAN_VERSION -ne 9 ]; then
|
if [ $DEBIAN_VERSION -ne 9 ]; then
|
||||||
echo "This script only work with Debian Stretch (9.x)"
|
echo "This script only work with Debian Stretch (9.x)"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -33,6 +33,7 @@ dpkg -i /tmp/linux-image-4.14.24-mptcp-64056fa.amd64.deb
|
||||||
dpkg -i /tmp/linux-headers-4.14.24-mptcp-64056fa.amd64.deb
|
dpkg -i /tmp/linux-headers-4.14.24-mptcp-64056fa.amd64.deb
|
||||||
|
|
||||||
# Check if mptcp kernel is grub default kernel
|
# Check if mptcp kernel is grub default kernel
|
||||||
|
echo "Set MPTCP kernel as grub default..."
|
||||||
wget -O /tmp/update-grub.sh http://www.openmptcprouter.com/server/update-grub.sh
|
wget -O /tmp/update-grub.sh http://www.openmptcprouter.com/server/update-grub.sh
|
||||||
cd /tmp
|
cd /tmp
|
||||||
bash update-grub.sh 4.14.24-mptcp
|
bash update-grub.sh 4.14.24-mptcp
|
||||||
|
@ -62,9 +63,13 @@ fi
|
||||||
wget -O /etc/sysctl.d/90-shadowsocks.conf http://www.openmptcprouter.com/server/shadowsocks.conf
|
wget -O /etc/sysctl.d/90-shadowsocks.conf http://www.openmptcprouter.com/server/shadowsocks.conf
|
||||||
|
|
||||||
# Install shadowsocks config and add a shadowsocks by CPU
|
# Install shadowsocks config and add a shadowsocks by CPU
|
||||||
wget -O /etc/shadowsocks-libev/config.json http://www.openmptcprouter.com/server/config.json
|
if [ ! -f /etc/shadowsocks-libev/config.json ]; then
|
||||||
SHADOWSOCKS_PASS_JSON=$(echo $SHADOWSOCKS_PASS | sed 's/+/-/g; s/\//_/g;')
|
wget -O /etc/shadowsocks-libev/config.json http://www.openmptcprouter.com/server/config.json
|
||||||
sed -i "s:MySecretKey:$SHADOWSOCKS_PASS_JSON:g" /etc/shadowsocks-libev/config.json
|
SHADOWSOCKS_PASS_JSON=$(echo $SHADOWSOCKS_PASS | sed 's/+/-/g; s/\//_/g;')
|
||||||
|
sed -i "s:MySecretKey:$SHADOWSOCKS_PASS_JSON:g" /etc/shadowsocks-libev/config.json
|
||||||
|
else
|
||||||
|
update=1
|
||||||
|
fi
|
||||||
#sed -i 's:json:json --mptcp:g' /lib/systemd/system/shadowsocks-libev-server@.service
|
#sed -i 's:json:json --mptcp:g' /lib/systemd/system/shadowsocks-libev-server@.service
|
||||||
systemctl disable shadowsocks-libev
|
systemctl disable shadowsocks-libev
|
||||||
systemctl enable shadowsocks-libev-server@config.service
|
systemctl enable shadowsocks-libev-server@config.service
|
||||||
|
@ -94,6 +99,9 @@ if [ "$OBFS" = "yes" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install Glorytun UDP
|
# Install Glorytun UDP
|
||||||
|
if systemctl -q is_active glorytun-udp@tun0.service; then
|
||||||
|
systemctl -q stop glorytun-udp@tun0 > /dev/null 2>&1
|
||||||
|
fi
|
||||||
apt-get -y install meson pkg-config ca-certificates
|
apt-get -y install meson pkg-config ca-certificates
|
||||||
cd /tmp
|
cd /tmp
|
||||||
wget -O /tmp/glorytun-0.0.99-mud.tar.gz https://github.com/angt/glorytun/releases/download/v0.0.99-mud/glorytun-0.0.99-mud.tar.gz
|
wget -O /tmp/glorytun-0.0.99-mud.tar.gz https://github.com/angt/glorytun/releases/download/v0.0.99-mud/glorytun-0.0.99-mud.tar.gz
|
||||||
|
@ -110,14 +118,20 @@ wget -O /lib/systemd/system/glorytun-udp@.service http://www.openmptcprouter.com
|
||||||
wget -O /lib/systemd/network/glorytun-udp.network http://www.openmptcprouter.com/server/glorytun-udp.network
|
wget -O /lib/systemd/network/glorytun-udp.network http://www.openmptcprouter.com/server/glorytun-udp.network
|
||||||
mkdir -p /etc/glorytun-udp
|
mkdir -p /etc/glorytun-udp
|
||||||
wget -O /etc/glorytun-udp/tun0 http://www.openmptcprouter.com/server/tun0.glorytun-udp
|
wget -O /etc/glorytun-udp/tun0 http://www.openmptcprouter.com/server/tun0.glorytun-udp
|
||||||
echo "$GLORYTUN_PASS" > /etc/glorytun-udp/tun0.key
|
if [ "$update" -eq "0" ]; then
|
||||||
|
echo "$GLORYTUN_PASS" > /etc/glorytun-udp/tun0.key
|
||||||
|
elif [ ! -f /etc/glorytun-udp/tun0.key ] && [ -f /etc/glorytun-tcp/tun0.key ]; then
|
||||||
|
cp /etc/glorytun-tcp/tun0.key /etc/glorytun-udp/tun0.key
|
||||||
|
fi
|
||||||
systemctl enable glorytun-udp@tun0.service
|
systemctl enable glorytun-udp@tun0.service
|
||||||
systemctl enable systemd-networkd.service
|
systemctl enable systemd-networkd.service
|
||||||
cd /tmp
|
cd /tmp
|
||||||
rm -r /tmp/glorytun-0.0.99-mud
|
rm -rf /tmp/glorytun-0.0.99-mud
|
||||||
|
|
||||||
|
|
||||||
# Install Glorytun TCP
|
# Install Glorytun TCP
|
||||||
|
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
|
apt -t stretch-backports -y install libsodium-dev
|
||||||
apt-get -y install build-essential pkg-config autoconf automake
|
apt-get -y install build-essential pkg-config autoconf automake
|
||||||
cd /tmp
|
cd /tmp
|
||||||
|
@ -135,7 +149,9 @@ wget -O /lib/systemd/system/glorytun-tcp@.service http://www.openmptcprouter.com
|
||||||
wget -O /lib/systemd/network/glorytun-tcp.network http://www.openmptcprouter.com/server/glorytun.network
|
wget -O /lib/systemd/network/glorytun-tcp.network http://www.openmptcprouter.com/server/glorytun.network
|
||||||
mkdir -p /etc/glorytun-tcp
|
mkdir -p /etc/glorytun-tcp
|
||||||
wget -O /etc/glorytun-tcp/tun0 http://www.openmptcprouter.com/server/tun0.glorytun
|
wget -O /etc/glorytun-tcp/tun0 http://www.openmptcprouter.com/server/tun0.glorytun
|
||||||
echo "$GLORYTUN_PASS" > /etc/glorytun-tcp/tun0.key
|
if [ "$update" -eq "0" ]; then
|
||||||
|
echo "$GLORYTUN_PASS" > /etc/glorytun-tcp/tun0.key
|
||||||
|
fi
|
||||||
systemctl enable glorytun-tcp@tun0.service
|
systemctl enable glorytun-tcp@tun0.service
|
||||||
systemctl enable systemd-networkd.service
|
systemctl enable systemd-networkd.service
|
||||||
cd /tmp
|
cd /tmp
|
||||||
|
@ -152,6 +168,7 @@ chmod 755 /usr/local/bin/omr-6in4
|
||||||
wget -O /usr/local/bin/omr-6in4-service http://www.openmptcprouter.com/server/omr-6in4-service
|
wget -O /usr/local/bin/omr-6in4-service http://www.openmptcprouter.com/server/omr-6in4-service
|
||||||
chmod 755 /usr/local/bin/omr-6in4-service
|
chmod 755 /usr/local/bin/omr-6in4-service
|
||||||
wget -O /lib/systemd/system/omr-6in4.service http://www.openmptcprouter.com/server/omr-6in4.service.in
|
wget -O /lib/systemd/system/omr-6in4.service http://www.openmptcprouter.com/server/omr-6in4.service.in
|
||||||
|
systemctl enable omr-6in4.service
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -165,56 +182,86 @@ sed -i 's:Port 22:Port 65222:g' /etc/ssh/sshd_config
|
||||||
# Remove fail2ban if available
|
# Remove fail2ban if available
|
||||||
#systemctl -q disable fail2ban
|
#systemctl -q disable fail2ban
|
||||||
|
|
||||||
# Install and configure the firewall using shorewall
|
if [ "$update" -eq "0" ]; then
|
||||||
apt-get -y install shorewall shorewall6
|
# Install and configure the firewall using shorewall
|
||||||
wget -O /etc/shorewall/openmptcprouter-shorewall.tar.gz http://www.openmptcprouter.com/server/openmptcprouter-shorewall.tar.gz
|
apt-get -y install shorewall shorewall6
|
||||||
tar xzf /etc/shorewall/openmptcprouter-shorewall.tar.gz -C /etc/shorewall
|
wget -O /etc/shorewall/openmptcprouter-shorewall.tar.gz http://www.openmptcprouter.com/server/openmptcprouter-shorewall.tar.gz
|
||||||
rm /etc/shorewall/openmptcprouter-shorewall.tar.gz
|
tar xzf /etc/shorewall/openmptcprouter-shorewall.tar.gz -C /etc/shorewall
|
||||||
sed -i "s:eth0:$INTERFACE:g" /etc/shorewall/*
|
rm /etc/shorewall/openmptcprouter-shorewall.tar.gz
|
||||||
systemctl enable shorewall
|
sed -i "s:eth0:$INTERFACE:g" /etc/shorewall/*
|
||||||
wget -O /etc/shorewall6/openmptcprouter-shorewall6.tar.gz http://www.openmptcprouter.com/server/openmptcprouter-shorewall6.tar.gz
|
systemctl enable shorewall
|
||||||
tar xzf /etc/shorewall6/openmptcprouter-shorewall6.tar.gz -C /etc/shorewall6
|
wget -O /etc/shorewall6/openmptcprouter-shorewall6.tar.gz http://www.openmptcprouter.com/server/openmptcprouter-shorewall6.tar.gz
|
||||||
rm /etc/shorewall6/openmptcprouter-shorewall6.tar.gz
|
tar xzf /etc/shorewall6/openmptcprouter-shorewall6.tar.gz -C /etc/shorewall6
|
||||||
sed -i "s:eth0:$INTERFACE:g" /etc/shorewall6/*
|
rm /etc/shorewall6/openmptcprouter-shorewall6.tar.gz
|
||||||
systemctl enable shorewall6
|
sed -i "s:eth0:$INTERFACE:g" /etc/shorewall6/*
|
||||||
|
systemctl enable shorewall6
|
||||||
|
else
|
||||||
|
# Update only needed firewall files
|
||||||
|
wget -O /etc/shorewall/interfaces http://www.openmptcprouter.com/server/shorewall4/interfaces
|
||||||
|
wget -O /etc/shorewall/snat http://www.openmptcprouter.com/server/shorewall4/snat
|
||||||
|
wget -O /etc/shorewall/stoppedrules http://www.openmptcprouter.com/server/shorewall4/stoppedrules
|
||||||
|
sed -i "s:eth0:$INTERFACE:g" /etc/shorewall/*
|
||||||
|
wget -O /etc/shorewall6/interfaces http://www.openmptcprouter.com/server/shorewall6/interfaces
|
||||||
|
wget -O /etc/shorewall6/stoppedrules http://www.openmptcprouter.com/server/shorewall6/stoppedrules
|
||||||
|
sed -i "s:eth0:$INTERFACE:g" /etc/shorewall6/*
|
||||||
|
fi
|
||||||
|
|
||||||
# Add OpenMPTCProuter VPS script version to /etc/motd
|
# Add OpenMPTCProuter VPS script version to /etc/motd
|
||||||
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 0.19 >:' /etc/motd
|
sed -i 's:< OpenMPTCProuter VPS [0-9]*\.[0-9]* >:< OpenMPCTProuter VPS 0.20 >:' /etc/motd
|
||||||
else
|
else
|
||||||
echo '< OpenMPCTProuter VPS 0.19 >' >> /etc/motd
|
echo '< OpenMPCTProuter VPS 0.20 >' >> /etc/motd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Display important info
|
if [ "$update" -eq "0" ]; then
|
||||||
echo '===================================================================================='
|
# Display important info
|
||||||
echo 'OpenMPTCProuter VPS is now configured !'
|
echo '===================================================================================='
|
||||||
echo 'SSH port: 65222 (instead of port 22)'
|
echo 'OpenMPTCProuter VPS is now configured !'
|
||||||
echo 'Shadowsocks port: 65101'
|
echo 'SSH port: 65222 (instead of port 22)'
|
||||||
echo 'Shadowsocks encryption: aes-256-cfb'
|
echo 'Shadowsocks port: 65101'
|
||||||
echo 'Your shadowsocks key: '
|
echo 'Shadowsocks encryption: aes-256-cfb'
|
||||||
echo $SHADOWSOCKS_PASS
|
echo 'Your shadowsocks key: '
|
||||||
echo 'Glorytun port: 65001'
|
echo $SHADOWSOCKS_PASS
|
||||||
echo 'Glorytun encryption: chacha20'
|
echo 'Glorytun port: 65001'
|
||||||
echo 'Your glorytun key: '
|
echo 'Glorytun encryption: chacha20'
|
||||||
echo $GLORYTUN_PASS
|
echo 'Your glorytun key: '
|
||||||
echo '===================================================================================='
|
echo $GLORYTUN_PASS
|
||||||
echo 'Keys are also saved in /root/openmptcprouter_config.txt, you are free to remove them'
|
echo '===================================================================================='
|
||||||
echo '===================================================================================='
|
echo 'Keys are also saved in /root/openmptcprouter_config.txt, you are free to remove them'
|
||||||
echo ' /!\ You need to reboot to enable MPTCP, shadowsocks, glorytun and shorewall /!\'
|
echo '===================================================================================='
|
||||||
echo '------------------------------------------------------------------------------------'
|
echo ' /!\ You need to reboot to enable MPTCP, shadowsocks, glorytun and shorewall /!\'
|
||||||
echo ' After reboot, check with uname -a that the kernel name contain mptcp.'
|
echo '------------------------------------------------------------------------------------'
|
||||||
echo ' Else, you may have to modify GRUB_DEFAULT in /etc/defaut/grub'
|
echo ' After reboot, check with uname -a that the kernel name contain mptcp.'
|
||||||
echo '===================================================================================='
|
echo ' Else, you may have to modify GRUB_DEFAULT in /etc/defaut/grub'
|
||||||
|
echo '===================================================================================='
|
||||||
|
|
||||||
# Save info in file
|
# Save info in file
|
||||||
cat > /root/openmptcprouter_config.txt <<EOF
|
cat > /root/openmptcprouter_config.txt <<-EOF
|
||||||
SSH port: 65222 (instead of port 22)
|
SSH port: 65222 (instead of port 22)
|
||||||
Shadowsocks port: 65101
|
Shadowsocks port: 65101
|
||||||
Shadowsocks encryption: aes-256-cfb
|
Shadowsocks encryption: aes-256-cfb
|
||||||
Your shadowsocks key:
|
Your shadowsocks key:
|
||||||
${SHADOWSOCKS_PASS}
|
${SHADOWSOCKS_PASS}
|
||||||
Glorytun port: 65001
|
Glorytun port: 65001
|
||||||
Glorytun encryption: chacha20
|
Glorytun encryption: chacha20
|
||||||
Your glorytun key:
|
Your glorytun key:
|
||||||
${GLORYTUN_PASS}
|
${GLORYTUN_PASS}
|
||||||
EOF
|
EOF
|
||||||
|
else
|
||||||
|
echo '===================================================================================='
|
||||||
|
echo 'OpenMPTCProuter VPS is now updated !'
|
||||||
|
echo 'Keys are not changed, shorewall rules files preserved'
|
||||||
|
echo '===================================================================================='
|
||||||
|
echo 'Restarting glorytun and omr-6in4...'
|
||||||
|
systemctl -q start glorytun-tcp@tun0
|
||||||
|
systemctl -q start glorytun-udp@tun0
|
||||||
|
systemctl -q restart omr-6in4
|
||||||
|
echo 'done'
|
||||||
|
echo 'Restarting shorewall...'
|
||||||
|
systemctl -q restart shorewall
|
||||||
|
systemctl -q restart shorewall6
|
||||||
|
echo 'done'
|
||||||
|
echo 'Restarting shadowsocks...'
|
||||||
|
systemctl -q restart shadowsocks
|
||||||
|
echo 'done'
|
||||||
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue