delete wg interfaces on netclient docker shutdown

This commit is contained in:
Matthew R. Kasun
2022-05-26 09:58:35 -04:00
parent 67837435ec
commit d34cf98932
13 changed files with 23 additions and 231 deletions

View File

@@ -1,4 +1,16 @@
#!/bin/sh
#!/bin/bash
#Define cleanup
cleanup() {
nets=($(wg show interfaces))
for net in ${nets[@]}; do
echo "deleting interface" $net
ip link del $net
done
}
#Trap SigTerm
trap 'cleanup' SIGTERM
echo "[netclient] joining network"
@@ -11,11 +23,12 @@ if [ "$TOKEN" != "" ]; then
TOKEN_CMD="-t $TOKEN"
fi
/root/netclient join $TOKEN_CMD -daemon off -dnson no -udpholepunch no
/root/netclient join $TOKEN_CMD -dnson no -udpholepunch no
if [ $? -ne 0 ]; then { echo "Failed to join, quitting." ; exit 1; } fi
echo "[netclient] Starting netclient daemon"
/root/netclient daemon
/root/netclient daemon &
wait $!
echo "[netclient] exiting"