2022-05-26 21:58:35 +08:00
|
|
|
#!/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
|
2021-11-29 17:34:11 +08:00
|
|
|
|
2021-09-29 06:24:10 +08:00
|
|
|
echo "[netclient] joining network"
|
|
|
|
|
2021-11-17 11:18:24 +08:00
|
|
|
if [ -z "${SLEEP}" ]; then
|
|
|
|
SLEEP=10
|
|
|
|
fi
|
|
|
|
|
|
|
|
TOKEN_CMD=""
|
|
|
|
if [ "$TOKEN" != "" ]; then
|
|
|
|
TOKEN_CMD="-t $TOKEN"
|
|
|
|
fi
|
|
|
|
|
2022-05-26 21:58:35 +08:00
|
|
|
/root/netclient join $TOKEN_CMD -dnson no -udpholepunch no
|
2021-11-29 17:34:11 +08:00
|
|
|
if [ $? -ne 0 ]; then { echo "Failed to join, quitting." ; exit 1; } fi
|
2021-09-29 06:24:10 +08:00
|
|
|
|
2022-02-09 12:55:45 +08:00
|
|
|
echo "[netclient] Starting netclient daemon"
|
|
|
|
|
2022-05-26 21:58:35 +08:00
|
|
|
/root/netclient daemon &
|
2022-02-09 12:55:45 +08:00
|
|
|
|
2022-05-26 21:58:35 +08:00
|
|
|
wait $!
|
2021-09-29 06:24:10 +08:00
|
|
|
echo "[netclient] exiting"
|