the ability to set the port for wireguard and shadowsocks at startup

This commit is contained in:
mercury
2023-02-14 03:00:08 +04:00
parent e27678432c
commit 111e5ffb8d
11 changed files with 59 additions and 23 deletions
+7
View File
@@ -1,4 +1,11 @@
cat /ssh/key.pub > /root/.ssh/authorized_keys
service ssh start
sed -n "s/\"server_port\": \([0-9]\+\),/\1/p" /config.json > current_port
CURRENT_PORT=$(cat current_port | tr -d " ")
if [ "$CURRENT_PORT" -ne "443" ]
then
sed "s/\"server_port\": [0-9]\+/\"server_port\": $SSPORT/" /config.json > change_port
cat change_port > /config.json
fi
/sslocal -v -d -c /config.json
tail -f /dev/null
+7
View File
@@ -1,4 +1,11 @@
cat /ssh/key.pub > /root/.ssh/authorized_keys
service ssh start
sed -n "s/\"server_port\": \([0-9]\+\),/\1/p" /config.json > current_port
CURRENT_PORT=$(cat current_port | tr -d " ")
if [ "$CURRENT_PORT" -ne "443" ]
then
sed "s/\"server_port\": [0-9]\+/\"server_port\": $SSPORT/" /config.json > change_port
cat change_port > /config.json
fi
/ssserver -v -d -c /config.json
tail -f /dev/null
+3 -1
View File
@@ -5,10 +5,12 @@ then
echo "[Interface]" > /etc/wireguard/wg0.conf
echo "PrivateKey = $PRIVATEKEY" >> /etc/wireguard/wg0.conf
echo "Address = $ADDRESS" >> /etc/wireguard/wg0.conf
echo "ListenPort = $PORT_WG" >> /etc/wireguard/wg0.conf
echo "ListenPort = $WGPORT" >> /etc/wireguard/wg0.conf
echo "PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o $INTERFACE -j MASQUERADE" >> /etc/wireguard/wg0.conf
echo "PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o $INTERFACE -j MASQUERADE" >> /etc/wireguard/wg0.conf
fi
sed "s/ListenPort = [0-9]\+/ListenPort = $WGPORT/" /etc/wireguard/wg0.conf > change_port
cat change_port > /etc/wireguard/wg0.conf
wg-quick up wg0
cat /ssh/key.pub > /root/.ssh/authorized_keys
service ssh start