29 lines
831 B
Bash
29 lines
831 B
Bash
#!/bin/bash
|
|
|
|
if [ "$(ls /wireguard/*.conf 2>/dev/null | wc -l)" == "0" ]; then
|
|
echo "---No WireGuard .conf file found!---"
|
|
sleep infinity
|
|
else
|
|
WG_CONF_FILE=$(ls /wireguard/*.conf 2>/dev/null | sort -V | head -1)
|
|
echo "---WireGuard config file found: ${WG_CONF_FILE}---"
|
|
cp ${WG_CONF_FILE} /etc/wireguard/wg0.conf
|
|
fi
|
|
|
|
echo "---Starting WireGuard tunnel---"
|
|
sudo wg-quick up wg0 > /dev/null 2>&1
|
|
EXIT_STATUS=$?
|
|
|
|
echo "---Adding iptables and killswitch---"
|
|
sudo /usr/local/bin/iptables-wg
|
|
|
|
if [ "${EXIT_STATUS}" != 0 ]; then
|
|
echo "---Can't start WireGuard tunnel, please check your config!---"
|
|
else
|
|
echo "---WireGuard tunnel started successfully...---"
|
|
if [ "${ENABLE_WEBCONSOLE}" == "true" ]; then
|
|
/opt/scripts/start-gotty.sh 2>/dev/null &
|
|
fi
|
|
fi
|
|
|
|
echo "Public IP: $(wget -qO- ipv4.icanhazip.com)"
|
|
sleep infinity |