2018-03-30 07:52:49 +00:00
|
|
|
#!/bin/sh
|
|
|
|
SHADOWSOCKS_PASS=${SHADOWSOCKS_PASS:-$(head -c 32 /dev/urandom | base64 -w0)}
|
|
|
|
GLORYTUN_PASS=${GLORYTUN_PASS:-$(od -vN "32" -An -tx1 /dev/urandom | tr '[:lower:]' '[:upper:]' | tr -d " \n")}
|
|
|
|
#NBCPU=${NBCPU:-$(nproc --all | tr -d "\n")}
|
|
|
|
NBCPU=${NBCPU:-$(grep -c '^processor' /proc/cpuinfo | tr -d "\n")}
|
|
|
|
OBFS=${OBFS:-no}
|
2018-11-28 21:18:35 +00:00
|
|
|
OMR_ADMIN=${OMR_ADMIN:-yes}
|
|
|
|
OMR_ADMIN_PASS=${OMR_ADMIN_PASS:-$(od -vN "32" -An -tx1 /dev/urandom | tr '[:lower:]' '[:upper:]' | tr -d " \n")}
|
2018-06-11 14:53:08 +00:00
|
|
|
MLVPN=${MLVPN:-no}
|
2018-11-28 21:18:35 +00:00
|
|
|
MLVPN_PASS=${MLVPN_PASS:-$(head -c 32 /dev/urandom | base64 -w0)}
|
2018-06-12 15:13:34 +00:00
|
|
|
OPENVPN=${OPENVPN:-no}
|
2018-11-02 08:03:59 +00:00
|
|
|
INTERFACE=${INTERFACE:-$(ip -o -4 route show to default | grep -Po '(?<=dev )(\S+)' | tr -d "\n")}
|
2018-11-28 21:18:35 +00:00
|
|
|
KERNEL_VERSION="4.14.79-mptcp-6ece8f4"
|
2018-11-30 09:31:36 +00:00
|
|
|
GLORYTUN_UDP_VERSION="8ff9d3d7a1481bd82578d98798360cf219f3b73a"
|
|
|
|
MLVPN_VERSION="8f9720978b28c1954f9f229525333547283316d2"
|
|
|
|
OBFS_VERSION="7659eeccf473aa41eb294e92c32f8f60a8747325"
|
|
|
|
SHADOWSOCKS_VERSION="3.2.3"
|
|
|
|
OMR_VERSION="0.70"
|
2018-03-30 07:52:49 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
umask 0022
|
2018-11-12 18:27:32 +00:00
|
|
|
|
2018-11-30 09:31:36 +00:00
|
|
|
rm -rf /var/lib/dpkg/lock
|
|
|
|
|
2018-11-12 18:27:32 +00:00
|
|
|
# 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
|
2018-05-04 06:28:28 +00:00
|
|
|
echo "This script only work with Debian Stretch (9.x)"
|
|
|
|
exit 1
|
2018-11-12 18:27:32 +00:00
|
|
|
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
|
2018-05-04 06:28:28 +00:00
|
|
|
fi
|
2018-11-12 18:27:32 +00:00
|
|
|
|
2018-06-08 15:17:06 +00:00
|
|
|
# Fix old string...
|
2018-11-12 18:27:32 +00:00
|
|
|
if [ -f /etc/motd ] && grep --quiet 'OpenMPCTProuter VPS' /etc/motd ; then
|
2018-06-08 15:17:06 +00:00
|
|
|
sed -i 's/OpenMPCTProuter/OpenMPTCProuter/g' /etc/motd
|
|
|
|
fi
|
2018-11-12 18:27:32 +00:00
|
|
|
|
2018-11-01 08:29:02 +00:00
|
|
|
# Check if OpenMPTCProuter VPS is already installed
|
2018-11-12 18:27:32 +00:00
|
|
|
update="0"
|
|
|
|
if [ -f /etc/motd ] && grep --quiet 'OpenMPTCProuter VPS' /etc/motd ; then
|
2018-06-05 15:25:30 +00:00
|
|
|
update="1"
|
2018-11-12 18:27:32 +00:00
|
|
|
elif [ -f /etc/motd.head ] && grep --quiet 'OpenMPTCProuter VPS' /etc/motd.head ; then
|
2018-11-01 08:29:02 +00:00
|
|
|
update="1"
|
2018-11-12 18:27:32 +00:00
|
|
|
elif [ -f /root/openmptcprouter_config.txt ]; then
|
2018-10-26 13:43:57 +00:00
|
|
|
update="1"
|
|
|
|
fi
|
2018-11-12 18:27:32 +00:00
|
|
|
|
2018-03-30 07:52:49 +00:00
|
|
|
# Install mptcp kernel and shadowsocks
|
|
|
|
apt-get update
|
2018-04-03 08:10:52 +00:00
|
|
|
apt-get -y install dirmngr patch
|
2018-03-30 07:52:49 +00:00
|
|
|
#apt-key adv --keyserver hkp://keys.gnupg.net --recv-keys 379CE192D401AB61
|
2018-11-12 18:27:32 +00:00
|
|
|
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
|
2018-03-30 07:52:49 +00:00
|
|
|
apt-get update
|
2018-08-21 05:56:46 +00:00
|
|
|
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
|
2018-05-14 20:08:27 +00:00
|
|
|
# Rename bzImage to vmlinuz, needed when custom kernel was used
|
2018-05-13 17:27:52 +00:00
|
|
|
cd /boot
|
2018-05-16 05:16:47 +00:00
|
|
|
apt-get -y install rename
|
2018-05-14 20:28:34 +00:00
|
|
|
rename 's/^bzImage/vmlinuz/s' * >/dev/null 2>&1
|
2018-03-30 07:52:49 +00:00
|
|
|
#apt-get -y install linux-mptcp
|
2018-11-12 18:27:32 +00:00
|
|
|
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
|
2018-03-30 07:52:49 +00:00
|
|
|
|
2018-06-01 13:11:58 +00:00
|
|
|
# Check if mptcp kernel is grub default kernel
|
2018-06-04 10:33:15 +00:00
|
|
|
echo "Set MPTCP kernel as grub default..."
|
2018-07-31 12:47:13 +00:00
|
|
|
wget -O /tmp/update-grub.sh https://www.openmptcprouter.com/server/update-grub.sh
|
2018-06-01 13:11:58 +00:00
|
|
|
cd /tmp
|
2018-08-21 05:56:46 +00:00
|
|
|
bash update-grub.sh ${KERNEL_VERSION}
|
2018-05-13 17:27:52 +00:00
|
|
|
|
2018-03-30 07:52:49 +00:00
|
|
|
#apt -t stretch-backports -y install shadowsocks-libev
|
|
|
|
## Compile Shadowsocks
|
2018-11-30 09:31:36 +00:00
|
|
|
rm -rf /tmp/shadowsocks-libev-${SHADOWSOCKS_VERSION}
|
|
|
|
wget -O /tmp/shadowsocks-libev-${SHADOWSOCKS_VERSION}.tar.gz http://github.com/shadowsocks/shadowsocks-libev/releases/download/v${SHADOWSOCKS_VERSION}/shadowsocks-libev-${SHADOWSOCKS_VERSION}.tar.gz
|
2018-03-30 07:52:49 +00:00
|
|
|
cd /tmp
|
2018-11-30 09:31:36 +00:00
|
|
|
tar xzf shadowsocks-libev-${SHADOWSOCKS_VERSION}.tar.gz
|
|
|
|
cd shadowsocks-libev-${SHADOWSOCKS_VERSION}
|
2018-06-11 14:53:08 +00:00
|
|
|
wget https://raw.githubusercontent.com/Ysurac/openmptcprouter-feeds/master/shadowsocks-libev/patches/020-NOCRYPTO.patch
|
2018-03-30 07:52:49 +00:00
|
|
|
patch -p1 < 020-NOCRYPTO.patch
|
|
|
|
apt-get -y install --no-install-recommends devscripts equivs apg libcap2-bin libpam-cap
|
2018-10-19 07:31:13 +00:00
|
|
|
apt-get -y install libc-ares2 libc-ares-dev libev4
|
2018-11-29 18:17:03 +00:00
|
|
|
# Install haveged entropy daemon
|
2018-11-12 18:27:32 +00:00
|
|
|
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
|
2018-05-04 06:28:28 +00:00
|
|
|
mk-build-deps --install --tool "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y"
|
2018-03-30 07:52:49 +00:00
|
|
|
dpkg-buildpackage -b -us -uc
|
|
|
|
cd ..
|
2018-11-30 09:31:36 +00:00
|
|
|
dpkg -i shadowsocks-libev_${SHADOWSOCKS_VERSION}-1_amd64.deb
|
|
|
|
rm -rf /tmp/shadowsocks-libev-${SHADOWSOCKS_VERSION}
|
2018-03-30 07:52:49 +00:00
|
|
|
|
|
|
|
# Load OLIA Congestion module at boot time
|
|
|
|
if ! grep -q olia /etc/modules ; then
|
|
|
|
echo mptcp_olia >> /etc/modules
|
|
|
|
fi
|
2018-11-28 21:18:35 +00:00
|
|
|
# Load WVEGAS Congestion module at boot time
|
|
|
|
if ! grep -q wvegas /etc/modules ; then
|
|
|
|
echo mptcp_wvegas >> /etc/modules
|
|
|
|
fi
|
|
|
|
# Load BALIA Congestion module at boot time
|
|
|
|
if ! grep -q balia /etc/modules ; then
|
|
|
|
echo mptcp_balia >> /etc/modules
|
|
|
|
fi
|
2018-08-02 13:14:16 +00:00
|
|
|
# Load BBR Congestion module at boot time
|
|
|
|
if ! grep -q bbr /etc/modules ; then
|
|
|
|
echo tcp_bbr >> /etc/modules
|
|
|
|
fi
|
2018-03-30 07:52:49 +00:00
|
|
|
|
2018-11-28 21:18:35 +00:00
|
|
|
if systemctl -q is-active omr-admin.service; then
|
|
|
|
systemctl -q stop omr-admin > /dev/null 2>&1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$OMR_ADMIN" = "yes" ]; then
|
|
|
|
echo 'Install OpenMPTCProuter VPS Admin'
|
|
|
|
apt-get -y install unzip gunicorn python3-flask-restful python3-openssl python3-pip
|
|
|
|
pip3 -q install flask-jwt-simple
|
|
|
|
mkdir -p /etc/openmptcprouter-vps-admin
|
|
|
|
wget -O /lib/systemd/system/omr-admin.service https://www.openmptcprouter.com/server/omr-admin.service.in
|
|
|
|
wget -O /tmp/openmptcprouter-vps-admin.zip https://github.com/Ysurac/openmptcprouter-vps-admin/archive/master.zip
|
|
|
|
cd /tmp
|
|
|
|
unzip -q -o openmptcprouter-vps-admin.zip
|
|
|
|
if [ -f /usr/local/bin/omr-admin.py ]; then
|
|
|
|
cp /tmp/openmptcprouter-vps-admin-master/omr-admin.py /usr/local/bin/
|
2018-11-29 08:10:52 +00:00
|
|
|
OMR_ADMIN_PASS=$(grep -Po '"pass":.*?[^\\]"' /etc/openmptcprouter-vps-admin/omr-admin-config.json | awk -F':' '{print $2}' | sed 's/"//g')
|
2018-11-28 21:18:35 +00:00
|
|
|
else
|
|
|
|
sed -i "s:MySecretKey:$OMR_ADMIN_PASS:g" /tmp/openmptcprouter-vps-admin-master/omr-admin-config.json
|
|
|
|
cp /tmp/openmptcprouter-vps-admin-master/omr-admin-config.json /etc/openmptcprouter-vps-admin/
|
|
|
|
cp /tmp/openmptcprouter-vps-admin-master/omr-admin.py /usr/local/bin/
|
|
|
|
cd /etc/openmptcprouter-vps-admin
|
|
|
|
openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout key.pem -out cert.pem -subj "/C=US/ST=Oregon/L=Portland/O=OpenMPTCProuterVPS/OU=Org/CN=www.openmptcprouter.vps"
|
|
|
|
fi
|
|
|
|
chmod u+x /usr/local/bin/omr-admin.py
|
|
|
|
systemctl enable omr-admin.service
|
|
|
|
rm -rf /tmp/tmp/openmptcprouter-vps-admin-master
|
|
|
|
fi
|
|
|
|
|
2018-03-30 07:52:49 +00:00
|
|
|
# Get shadowsocks optimization
|
2018-07-31 12:47:13 +00:00
|
|
|
wget -O /etc/sysctl.d/90-shadowsocks.conf https://www.openmptcprouter.com/server/shadowsocks.conf
|
2018-03-30 07:52:49 +00:00
|
|
|
|
|
|
|
# Install shadowsocks config and add a shadowsocks by CPU
|
2018-06-05 15:25:30 +00:00
|
|
|
if [ "$update" = "0" ]; then
|
2018-07-31 12:47:13 +00:00
|
|
|
wget -O /etc/shadowsocks-libev/config.json https://www.openmptcprouter.com/server/config.json
|
2018-06-04 10:33:15 +00:00
|
|
|
SHADOWSOCKS_PASS_JSON=$(echo $SHADOWSOCKS_PASS | sed 's/+/-/g; s/\//_/g;')
|
|
|
|
sed -i "s:MySecretKey:$SHADOWSOCKS_PASS_JSON:g" /etc/shadowsocks-libev/config.json
|
|
|
|
fi
|
2018-08-02 13:14:16 +00:00
|
|
|
sed -i 's:aes-256-cfb:chacha20:g' /etc/shadowsocks-libev/config.json
|
2018-11-01 08:29:02 +00:00
|
|
|
sed -i 's:json:json --no-delay:g' /lib/systemd/system/shadowsocks-libev-server@.service
|
2018-03-30 07:52:49 +00:00
|
|
|
systemctl disable shadowsocks-libev
|
|
|
|
systemctl enable shadowsocks-libev-server@config.service
|
|
|
|
if [ $NBCPU -gt 1 ]; then
|
|
|
|
for i in $NBCPU; do
|
|
|
|
ln -fs /etc/shadowsocks-libev/config.json /etc/shadowsocks-libev/config$i.json
|
|
|
|
systemctl enable shadowsocks-libev-server@config$i.service
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
if ! grep -q 'DefaultLimitNOFILE=65536' /etc/systemd/system.conf ; then
|
|
|
|
echo 'DefaultLimitNOFILE=65536' >> /etc/systemd/system.conf
|
|
|
|
fi
|
|
|
|
# Install simple-obfs
|
|
|
|
if [ "$OBFS" = "yes" ]; then
|
2018-11-28 21:18:35 +00:00
|
|
|
echo "Install OBFS"
|
2018-07-07 08:59:46 +00:00
|
|
|
rm -rf /tmp/simple-obfs
|
2018-03-30 07:52:49 +00:00
|
|
|
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
|
|
|
|
git clone https://github.com/shadowsocks/simple-obfs.git /tmp/simple-obfs
|
|
|
|
cd /tmp/simple-obfs
|
2018-11-30 09:31:36 +00:00
|
|
|
git checkout ${OBFS_VERSION}
|
2018-03-30 07:52:49 +00:00
|
|
|
git submodule update --init --recursive
|
|
|
|
./autogen.sh
|
|
|
|
./configure && make
|
|
|
|
make install
|
|
|
|
cd /tmp
|
|
|
|
rm -rf /tmp/simple-obfs
|
2018-07-27 07:54:11 +00:00
|
|
|
sed -i 's%"mptcp": true%"mptcp": true,\n"plugin": "/usr/local/bin/obfs-server",\n"plugin_opts": "obfs=http;mptcp;fast-open;t=400"%' /etc/shadowsocks-libev/config.json
|
2018-06-28 12:43:26 +00:00
|
|
|
else
|
|
|
|
sed -i -e '/plugin/d' -e 's/,,//' /etc/shadowsocks-libev/config.json
|
2018-03-30 07:52:49 +00:00
|
|
|
fi
|
|
|
|
|
2018-11-28 21:18:35 +00:00
|
|
|
if systemctl -q is-active mlvpn@mlvpn0.service; then
|
|
|
|
systemctl -q stop mlvpn@mlvpn0 > /dev/null 2>&1
|
|
|
|
systemctl -q disable mlvpn@mlvpn0 > /dev/null 2>&1
|
|
|
|
fi
|
|
|
|
echo "install mlvpn"
|
|
|
|
# Install MLVPN
|
2018-06-11 14:53:08 +00:00
|
|
|
if [ "$MLVPN" = "yes" ]; then
|
2018-11-28 21:18:35 +00:00
|
|
|
echo 'Install MLVPN'
|
|
|
|
mlvpnupdate="0"
|
|
|
|
if [ -f /etc/mlvpn/mlvpn0.conf ]; then
|
|
|
|
mlvpnupdate="1"
|
|
|
|
fi
|
2018-11-30 09:31:36 +00:00
|
|
|
apt-get -y install build-essential pkg-config autoconf automake libpcap-dev unzip git
|
|
|
|
rm -rf /tmp/mlvpn
|
2018-06-11 14:53:08 +00:00
|
|
|
cd /tmp
|
2018-11-30 09:31:36 +00:00
|
|
|
git clone https://github.com/markfoodyburton/MLVPN.git /tmp/mlvpn
|
|
|
|
cd /tmp/mlvpn
|
|
|
|
git checkout ${MLVPN_VERSION}
|
2018-11-28 21:18:35 +00:00
|
|
|
./autogen.sh
|
|
|
|
./configure --sysconfdir=/etc
|
|
|
|
make
|
|
|
|
make install
|
|
|
|
wget -O /lib/systemd/network/mlvpn.network https://www.openmptcprouter.com/server/mlvpn.network
|
|
|
|
mkdir -p /etc/mlvpn
|
|
|
|
if [ "$mlvpnupdate" = "0" ]; then
|
|
|
|
wget -O /etc/mlvpn/mlvpn0.conf https://www.openmptcprouter.com/server/mlvpn0.conf
|
|
|
|
sed -i "s:MLVPN_PASS:$MLVPN_PASS:" /etc/mlvpn/mlvpn0.conf
|
|
|
|
fi
|
|
|
|
chmod 0600 /etc/mlvpn/mlvpn0.conf
|
|
|
|
adduser --quiet --system --home /var/opt/mlvpn --shell /usr/sbin/nologin mlvpn
|
|
|
|
mkdir -p /var/opt/mlvpn
|
|
|
|
usermod -d /var/opt/mlvpn mlvpn
|
|
|
|
chown mlvpn /var/opt/mlvpn
|
|
|
|
systemctl enable mlvpn@mlvpn0.service
|
|
|
|
systemctl enable systemd-networkd.service
|
|
|
|
cd /tmp
|
2018-11-30 09:31:36 +00:00
|
|
|
rm -rf /tmp/mlvpn
|
2018-06-12 15:13:34 +00:00
|
|
|
fi
|
2018-11-28 21:18:35 +00:00
|
|
|
echo "install mlvpn done"
|
2018-07-31 12:47:13 +00:00
|
|
|
if systemctl -q is-active openvpn-server@tun0.service; then
|
|
|
|
systemctl -q stop openvpn-server@tun0 > /dev/null 2>&1
|
|
|
|
systemctl -q disable openvpn-server@tun0 > /dev/null 2>&1
|
|
|
|
fi
|
2018-06-12 15:13:34 +00:00
|
|
|
if [ "$OPENVPN" = "yes" ]; then
|
2018-11-28 21:18:35 +00:00
|
|
|
echo "Install OpenVPN"
|
2018-06-12 15:13:34 +00:00
|
|
|
apt-get -y install openvpn
|
2018-07-31 12:47:13 +00:00
|
|
|
wget -O /lib/systemd/network/openvpn.network https://www.openmptcprouter.com/server/openvpn.network
|
2018-06-12 15:13:34 +00:00
|
|
|
if [ ! -f "/etc/openvpn/server/static.key" ]; then
|
2018-07-31 12:47:13 +00:00
|
|
|
wget -O /etc/openvpn/tun0.conf https://www.openmptcprouter.com/server/openvpn-tun0.conf
|
2018-06-12 15:13:34 +00:00
|
|
|
cd /etc/openvpn/server
|
|
|
|
openvpn --genkey --secret static.key
|
|
|
|
fi
|
2018-07-31 12:47:13 +00:00
|
|
|
systemctl enable openvpn@tun0.service
|
2018-06-11 14:53:08 +00:00
|
|
|
fi
|
|
|
|
|
2018-11-28 21:18:35 +00:00
|
|
|
echo 'Glorytun UDP'
|
2018-03-30 07:52:49 +00:00
|
|
|
# Install Glorytun UDP
|
2018-06-04 10:50:02 +00:00
|
|
|
if systemctl -q is-active glorytun-udp@tun0.service; then
|
2018-06-04 10:33:15 +00:00
|
|
|
systemctl -q stop glorytun-udp@tun0 > /dev/null 2>&1
|
|
|
|
fi
|
2018-11-30 09:31:36 +00:00
|
|
|
apt-get install -y --no-install-recommends build-essential git ca-certificates meson pkg-config
|
|
|
|
rm -rf /tmp/glorytun-udp
|
2018-06-01 13:11:58 +00:00
|
|
|
cd /tmp
|
2018-11-30 09:31:36 +00:00
|
|
|
git clone https://github.com/angt/glorytun.git /tmp/glorytun-udp
|
|
|
|
cd /tmp/glorytun-udp
|
|
|
|
git checkout ${GLORYTUN_UDP_VERSION}
|
|
|
|
git submodule update --init --recursive
|
2018-06-01 13:11:58 +00:00
|
|
|
meson build
|
|
|
|
ninja -C build install
|
|
|
|
sed -i 's:EmitDNS=yes:EmitDNS=no:g' /lib/systemd/network/glorytun.network
|
|
|
|
rm /lib/systemd/system/glorytun*
|
|
|
|
rm /lib/systemd/network/glorytun*
|
2018-07-31 12:47:13 +00:00
|
|
|
wget -O /usr/local/bin/glorytun-udp-run https://www.openmptcprouter.com/server/glorytun-udp-run
|
2018-06-04 10:50:02 +00:00
|
|
|
chmod 755 /usr/local/bin/glorytun-udp-run
|
2018-07-31 12:47:13 +00:00
|
|
|
wget -O /lib/systemd/system/glorytun-udp@.service https://www.openmptcprouter.com/server/glorytun-udp%40.service.in
|
|
|
|
wget -O /lib/systemd/network/glorytun-udp.network https://www.openmptcprouter.com/server/glorytun-udp.network
|
2018-06-01 13:11:58 +00:00
|
|
|
mkdir -p /etc/glorytun-udp
|
2018-07-31 12:47:13 +00:00
|
|
|
wget -O /etc/glorytun-udp/tun0 https://www.openmptcprouter.com/server/tun0.glorytun-udp
|
2018-06-05 15:25:30 +00:00
|
|
|
if [ "$update" = "0" ]; then
|
2018-06-04 10:33:15 +00:00
|
|
|
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
|
2018-06-01 13:11:58 +00:00
|
|
|
systemctl enable glorytun-udp@tun0.service
|
|
|
|
systemctl enable systemd-networkd.service
|
|
|
|
cd /tmp
|
2018-11-30 09:31:36 +00:00
|
|
|
rm -rf /tmp/glorytun-udp
|
2018-03-30 07:52:49 +00:00
|
|
|
|
|
|
|
# Install Glorytun TCP
|
2018-06-04 10:50:02 +00:00
|
|
|
if systemctl -q is-active glorytun-tcp@tun0.service; then
|
2018-06-04 10:33:15 +00:00
|
|
|
systemctl -q stop glorytun-tcp@tun0 > /dev/null 2>&1
|
|
|
|
fi
|
2018-11-12 18:27:32 +00:00
|
|
|
if [ "$ID" = "debian" ]; then
|
|
|
|
apt -t stretch-backports -y install libsodium-dev
|
|
|
|
elif [ "$ID" = "ubuntu" ]; then
|
|
|
|
apt-get -y install libsodium-dev
|
|
|
|
fi
|
2018-03-30 07:52:49 +00:00
|
|
|
apt-get -y install build-essential pkg-config autoconf automake
|
2018-07-07 08:59:46 +00:00
|
|
|
rm -rf /tmp/glorytun-0.0.35
|
2018-03-30 07:52:49 +00:00
|
|
|
cd /tmp
|
|
|
|
wget -O /tmp/glorytun-0.0.35.tar.gz http://github.com/angt/glorytun/releases/download/v0.0.35/glorytun-0.0.35.tar.gz
|
|
|
|
tar xzf glorytun-0.0.35.tar.gz
|
|
|
|
cd glorytun-0.0.35
|
|
|
|
./autogen.sh
|
|
|
|
./configure
|
|
|
|
make
|
|
|
|
cp glorytun /usr/local/bin/glorytun-tcp
|
2018-07-31 12:47:13 +00:00
|
|
|
wget -O /usr/local/bin/glorytun-tcp-run https://www.openmptcprouter.com/server/glorytun-tcp-run
|
2018-03-30 07:52:49 +00:00
|
|
|
chmod 755 /usr/local/bin/glorytun-tcp-run
|
2018-07-31 12:47:13 +00:00
|
|
|
wget -O /lib/systemd/system/glorytun-tcp@.service https://www.openmptcprouter.com/server/glorytun-tcp%40.service.in
|
|
|
|
wget -O /lib/systemd/network/glorytun-tcp.network https://www.openmptcprouter.com/server/glorytun.network
|
2018-03-30 07:52:49 +00:00
|
|
|
mkdir -p /etc/glorytun-tcp
|
2018-07-31 12:47:13 +00:00
|
|
|
wget -O /etc/glorytun-tcp/tun0 https://www.openmptcprouter.com/server/tun0.glorytun
|
2018-06-05 15:25:30 +00:00
|
|
|
if [ "$update" = "0" ]; then
|
2018-06-04 10:33:15 +00:00
|
|
|
echo "$GLORYTUN_PASS" > /etc/glorytun-tcp/tun0.key
|
|
|
|
fi
|
2018-03-30 07:52:49 +00:00
|
|
|
systemctl enable glorytun-tcp@tun0.service
|
|
|
|
systemctl enable systemd-networkd.service
|
|
|
|
cd /tmp
|
2018-07-07 08:59:46 +00:00
|
|
|
rm -rf /tmp/glorytun-0.0.35
|
2018-03-30 07:52:49 +00:00
|
|
|
|
|
|
|
# Load tun module at boot time
|
|
|
|
if ! grep -q tun /etc/modules ; then
|
|
|
|
echo tun >> /etc/modules
|
|
|
|
fi
|
|
|
|
|
2018-07-27 12:40:12 +00:00
|
|
|
# Add multipath utility
|
2018-07-31 12:47:13 +00:00
|
|
|
wget -O /usr/local/bin/multipath https://www.openmptcprouter.com/server/multipath
|
2018-07-27 12:40:12 +00:00
|
|
|
chmod 755 /usr/local/bin/multipath
|
2018-06-01 13:11:58 +00:00
|
|
|
|
2018-07-27 12:40:12 +00:00
|
|
|
# Add OpenMPTCProuter service
|
2018-07-31 12:47:13 +00:00
|
|
|
wget -O /usr/local/bin/omr-service https://www.openmptcprouter.com/server/omr-service
|
2018-07-27 12:40:12 +00:00
|
|
|
chmod 755 /usr/local/bin/omr-service
|
2018-07-31 12:47:13 +00:00
|
|
|
wget -O /lib/systemd/system/omr.service https://www.openmptcprouter.com/server/omr.service.in
|
2018-07-27 12:40:12 +00:00
|
|
|
if systemctl -q is-active omr-6in4.service; then
|
|
|
|
systemctl -q stop omr-6in4 > /dev/null 2>&1
|
2018-07-28 18:34:00 +00:00
|
|
|
systemctl -q disable omr-6in4 > /dev/null 2>&1
|
2018-07-27 12:40:12 +00:00
|
|
|
fi
|
|
|
|
systemctl enable omr.service
|
2018-06-01 13:11:58 +00:00
|
|
|
|
2018-03-30 07:52:49 +00:00
|
|
|
|
|
|
|
# Change SSH port to 65222
|
|
|
|
sed -i 's:#Port 22:Port 65222:g' /etc/ssh/sshd_config
|
|
|
|
sed -i 's:Port 22:Port 65222:g' /etc/ssh/sshd_config
|
|
|
|
|
|
|
|
# Remove Bind9 if available
|
|
|
|
#systemctl -q disable bind9
|
|
|
|
|
|
|
|
# Remove fail2ban if available
|
|
|
|
#systemctl -q disable fail2ban
|
|
|
|
|
2018-06-05 15:25:30 +00:00
|
|
|
if [ "$update" = "0" ]; then
|
2018-06-04 10:33:15 +00:00
|
|
|
# Install and configure the firewall using shorewall
|
|
|
|
apt-get -y install shorewall shorewall6
|
2018-07-31 12:47:13 +00:00
|
|
|
wget -O /etc/shorewall/openmptcprouter-shorewall.tar.gz https://www.openmptcprouter.com/server/openmptcprouter-shorewall.tar.gz
|
2018-06-04 10:33:15 +00:00
|
|
|
tar xzf /etc/shorewall/openmptcprouter-shorewall.tar.gz -C /etc/shorewall
|
|
|
|
rm /etc/shorewall/openmptcprouter-shorewall.tar.gz
|
|
|
|
sed -i "s:eth0:$INTERFACE:g" /etc/shorewall/*
|
|
|
|
systemctl enable shorewall
|
2018-07-31 12:47:13 +00:00
|
|
|
wget -O /etc/shorewall6/openmptcprouter-shorewall6.tar.gz https://www.openmptcprouter.com/server/openmptcprouter-shorewall6.tar.gz
|
2018-06-04 10:33:15 +00:00
|
|
|
tar xzf /etc/shorewall6/openmptcprouter-shorewall6.tar.gz -C /etc/shorewall6
|
|
|
|
rm /etc/shorewall6/openmptcprouter-shorewall6.tar.gz
|
|
|
|
sed -i "s:eth0:$INTERFACE:g" /etc/shorewall6/*
|
|
|
|
systemctl enable shorewall6
|
|
|
|
else
|
|
|
|
# Update only needed firewall files
|
2018-07-31 12:47:13 +00:00
|
|
|
wget -O /etc/shorewall/interfaces https://www.openmptcprouter.com/server/shorewall4/interfaces
|
|
|
|
wget -O /etc/shorewall/snat https://www.openmptcprouter.com/server/shorewall4/snat
|
|
|
|
wget -O /etc/shorewall/stoppedrules https://www.openmptcprouter.com/server/shorewall4/stoppedrules
|
|
|
|
wget -O /etc/shorewall/params https://www.openmptcprouter.com/server/shorewall4/params
|
|
|
|
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
|
2018-06-04 10:33:15 +00:00
|
|
|
sed -i "s:eth0:$INTERFACE:g" /etc/shorewall/*
|
2018-06-13 17:45:53 +00:00
|
|
|
sed -i 's:10.0.0.2:$OMR_ADDR:g' /etc/shorewall/rules
|
2018-07-31 12:47:13 +00:00
|
|
|
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/interfaces https://www.openmptcprouter.com/server/shorewall6/interfaces
|
|
|
|
wget -O /etc/shorewall6/stoppedrules https://www.openmptcprouter.com/server/shorewall6/stoppedrules
|
|
|
|
wget -O /etc/shorewall6/snat https://www.openmptcprouter.com/server/shorewall6/snat
|
2018-06-04 10:33:15 +00:00
|
|
|
sed -i "s:eth0:$INTERFACE:g" /etc/shorewall6/*
|
|
|
|
fi
|
2018-03-30 07:52:49 +00:00
|
|
|
|
|
|
|
# Add OpenMPTCProuter VPS script version to /etc/motd
|
2018-10-26 13:43:57 +00:00
|
|
|
if [ -f /etc/motd.head ]; then
|
2018-10-19 07:31:13 +00:00
|
|
|
if grep --quiet 'OpenMPTCProuter VPS' /etc/motd.head; then
|
2018-11-01 08:29:02 +00:00
|
|
|
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
|
2018-10-19 07:31:13 +00:00
|
|
|
else
|
2018-11-01 08:29:02 +00:00
|
|
|
echo "< OpenMPTCProuter VPS $OMR_VERSION >" >> /etc/motd.head
|
2018-10-19 07:31:13 +00:00
|
|
|
fi
|
2018-10-26 13:43:57 +00:00
|
|
|
elif [ -f /etc/motd ]; then
|
|
|
|
if grep --quiet 'OpenMPTCProuter VPS' /etc/motd; then
|
2018-11-01 08:29:02 +00:00
|
|
|
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
|
2018-10-26 13:43:57 +00:00
|
|
|
else
|
2018-11-01 08:29:02 +00:00
|
|
|
echo "< OpenMPTCProuter VPS $OMR_VERSION >" >> /etc/motd
|
2018-10-26 13:43:57 +00:00
|
|
|
fi
|
2018-11-01 08:29:02 +00:00
|
|
|
else
|
|
|
|
echo "< OpenMPTCProuter VPS $OMR_VERSION >" > /etc/motd
|
2018-03-30 07:52:49 +00:00
|
|
|
fi
|
|
|
|
|
2018-06-05 15:25:30 +00:00
|
|
|
if [ "$update" = "0" ]; then
|
2018-06-04 10:33:15 +00:00
|
|
|
# Display important info
|
|
|
|
echo '===================================================================================='
|
|
|
|
echo 'OpenMPTCProuter VPS is now configured !'
|
|
|
|
echo 'SSH port: 65222 (instead of port 22)'
|
2018-11-28 21:18:35 +00:00
|
|
|
if [ "$OMR_ADMIN" = "yes" ]; then
|
|
|
|
echo '===================================================================================='
|
|
|
|
echo '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
|
|
|
|
echo 'OpenMPTCProuter VPS admin key (you need OpenMPTCProuter >= 0.42):'
|
|
|
|
echo $OMR_ADMIN_PASS
|
|
|
|
echo '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
|
|
|
|
echo '===================================================================================='
|
|
|
|
fi
|
2018-06-04 10:33:15 +00:00
|
|
|
echo 'Shadowsocks port: 65101'
|
2018-08-02 13:14:16 +00:00
|
|
|
echo 'Shadowsocks encryption: chacha20'
|
2018-06-04 10:33:15 +00:00
|
|
|
echo 'Your shadowsocks key: '
|
|
|
|
echo $SHADOWSOCKS_PASS
|
|
|
|
echo 'Glorytun port: 65001'
|
|
|
|
echo 'Glorytun encryption: chacha20'
|
|
|
|
echo 'Your glorytun key: '
|
|
|
|
echo $GLORYTUN_PASS
|
2018-11-28 21:18:35 +00:00
|
|
|
if [ "$MLVPN" = "yes" ]; then
|
|
|
|
echo 'MLVPN first port: 65201'
|
|
|
|
echo 'Your MLVPN password: '
|
|
|
|
echo $MLVPN_PASS
|
|
|
|
fi
|
2018-06-04 10:33:15 +00:00
|
|
|
echo '===================================================================================='
|
|
|
|
echo 'Keys are also saved in /root/openmptcprouter_config.txt, you are free to remove them'
|
|
|
|
echo '===================================================================================='
|
|
|
|
echo ' /!\ You need to reboot to enable MPTCP, shadowsocks, glorytun and shorewall /!\'
|
|
|
|
echo '------------------------------------------------------------------------------------'
|
|
|
|
echo ' After reboot, check with uname -a that the kernel name contain mptcp.'
|
|
|
|
echo ' Else, you may have to modify GRUB_DEFAULT in /etc/defaut/grub'
|
|
|
|
echo '===================================================================================='
|
|
|
|
|
|
|
|
# Save info in file
|
|
|
|
cat > /root/openmptcprouter_config.txt <<-EOF
|
|
|
|
SSH port: 65222 (instead of port 22)
|
|
|
|
Shadowsocks port: 65101
|
2018-08-02 13:14:16 +00:00
|
|
|
Shadowsocks encryption: chacha20
|
2018-11-12 18:27:32 +00:00
|
|
|
Your shadowsocks key: ${SHADOWSOCKS_PASS}
|
2018-06-04 10:33:15 +00:00
|
|
|
Glorytun port: 65001
|
|
|
|
Glorytun encryption: chacha20
|
2018-11-12 18:27:32 +00:00
|
|
|
Your glorytun key: ${GLORYTUN_PASS}
|
2018-06-04 10:33:15 +00:00
|
|
|
EOF
|
2018-11-28 21:18:35 +00:00
|
|
|
if [ "$MLVPN" = "yes" ]; then
|
|
|
|
cat >> /root/openmptcprouter_config.txt <<-EOF
|
|
|
|
MLVPN first port: 65201'
|
|
|
|
Your MLVPN password: $MLVPN_PASS
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
if [ "$OMR_ADMIN" = "yes" ]; then
|
|
|
|
cat >> /root/openmptcprouter_config.txt <<-EOF
|
|
|
|
Your OpenMPTCProuter VPS Admin key: $OMR_ADMIN_PASS
|
|
|
|
EOF
|
2018-06-11 14:53:08 +00:00
|
|
|
fi
|
2018-06-04 10:33:15 +00:00
|
|
|
else
|
|
|
|
echo '===================================================================================='
|
|
|
|
echo 'OpenMPTCProuter VPS is now updated !'
|
|
|
|
echo 'Keys are not changed, shorewall rules files preserved'
|
2018-08-02 13:14:16 +00:00
|
|
|
echo 'You need OpenMPTCProuter >= 0.30'
|
2018-06-04 10:33:15 +00:00
|
|
|
echo '===================================================================================='
|
2018-06-13 08:18:43 +00:00
|
|
|
echo 'Restarting systemd network...'
|
|
|
|
systemctl -q restart systemd-networkd
|
|
|
|
echo 'done'
|
2018-11-28 21:18:35 +00:00
|
|
|
if [ "$MLVPN" = "yes" ]; then
|
|
|
|
echo 'Restarting mlvpn...'
|
|
|
|
systemctl -q start mlvpn@mlvpn0
|
|
|
|
echo 'done'
|
|
|
|
fi
|
2018-07-27 12:40:12 +00:00
|
|
|
echo 'Restarting glorytun and omr...'
|
2018-06-04 10:33:15 +00:00
|
|
|
systemctl -q start glorytun-tcp@tun0
|
|
|
|
systemctl -q start glorytun-udp@tun0
|
2018-07-27 12:40:12 +00:00
|
|
|
systemctl -q restart omr
|
2018-06-04 10:33:15 +00:00
|
|
|
echo 'done'
|
2018-06-12 15:13:34 +00:00
|
|
|
if [ "$OPENVPN" = "yes" ]; then
|
|
|
|
echo 'Restarting OpenVPN'
|
2018-07-31 12:47:13 +00:00
|
|
|
systemctl -q restart openvpn@tun0
|
2018-06-12 15:13:34 +00:00
|
|
|
echo 'done'
|
|
|
|
fi
|
2018-11-28 21:18:35 +00:00
|
|
|
if [ "$OMR_ADMIN" = "yes" ]; then
|
|
|
|
echo 'Restarting OpenMPTCProuter VPS admin'
|
|
|
|
systemctl -q restart omr-admin
|
|
|
|
echo 'done'
|
2018-11-29 08:10:52 +00:00
|
|
|
if ! grep -q 'VPS Admin key' /root/openmptcprouter_config.txt ; then
|
|
|
|
cat >> /root/openmptcprouter_config.txt <<-EOF
|
|
|
|
Your OpenMPTCProuter VPS Admin key: $OMR_ADMIN_PASS
|
|
|
|
EOF
|
|
|
|
echo '===================================================================================='
|
|
|
|
echo '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
|
|
|
|
echo 'OpenMPTCProuter VPS admin key (you need OpenMPTCProuter >= 0.42):'
|
|
|
|
echo $OMR_ADMIN_PASS
|
|
|
|
echo '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
|
|
|
|
echo '===================================================================================='
|
|
|
|
fi
|
2018-11-28 21:18:35 +00:00
|
|
|
fi
|
2018-07-02 12:23:35 +00:00
|
|
|
echo 'Restarting shorewall...'
|
|
|
|
systemctl -q restart shorewall
|
|
|
|
systemctl -q restart shorewall6
|
|
|
|
echo 'done'
|
2018-08-02 13:14:16 +00:00
|
|
|
echo 'Apply latest sysctl...'
|
|
|
|
sysctl -p /etc/sysctl.d/90-shadowsocks.conf > /dev/null 2>&1
|
|
|
|
echo 'done'
|
2018-11-29 08:10:52 +00:00
|
|
|
echo 'Restarting shadowsocks...'
|
|
|
|
systemctl -q restart shadowsocks-libev-server@config
|
|
|
|
if [ $NBCPU -gt 1 ]; then
|
|
|
|
for i in $NBCPU; do
|
|
|
|
systemctl restart shadowsocks-libev-server@config$i
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
echo 'done'
|
2018-06-04 10:33:15 +00:00
|
|
|
fi
|