2021-09-29 06:24:10 +08:00
|
|
|
#!/bin/sh
|
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
|
|
|
|
|
2021-12-12 01:39:22 +08:00
|
|
|
/root/netclient join $TOKEN_CMD -daemon off -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
|
|
|
|
|
|
|
echo "[netclient] Starting netclient checkin"
|
|
|
|
# loop and call checkin -n all
|
2021-11-29 18:28:08 +08:00
|
|
|
FAILCOUNT=0
|
2021-09-29 06:24:10 +08:00
|
|
|
while [ 1 ]; do
|
|
|
|
# add logs to netclient.logs
|
2021-11-17 11:18:24 +08:00
|
|
|
/root/netclient checkin -n all
|
2021-11-29 18:28:08 +08:00
|
|
|
if [ $? -ne 0 ]; then FAILCOUNT=$((FAILCOUNT+1)) ; else FAILCOUNT=0; fi
|
|
|
|
if [ $FAILCOUNT -gt 2 ]; then { echo "Failing checkins frequently, restarting." ; exit 1; } fi
|
2021-09-29 06:24:10 +08:00
|
|
|
sleep $SLEEP
|
|
|
|
done
|
|
|
|
echo "[netclient] exiting"
|