netclient.sh 703 B

123456789101112131415161718192021222324252627
  1. #!/bin/sh
  2. echo "[netclient] joining network"
  3. if [ -z "${SLEEP}" ]; then
  4. SLEEP=10
  5. fi
  6. TOKEN_CMD=""
  7. if [ "$TOKEN" != "" ]; then
  8. TOKEN_CMD="-t $TOKEN"
  9. fi
  10. /root/netclient join $TOKEN_CMD -daemon off -dnson no -udpholepunch no
  11. if [ $? -ne 0 ]; then { echo "Failed to join, quitting." ; exit 1; } fi
  12. echo "[netclient] Starting netclient checkin"
  13. # loop and call checkin -n all
  14. FAILCOUNT=0
  15. while [ 1 ]; do
  16. # add logs to netclient.logs
  17. /root/netclient checkin -n all
  18. if [ $? -ne 0 ]; then FAILCOUNT=$((FAILCOUNT+1)) ; else FAILCOUNT=0; fi
  19. if [ $FAILCOUNT -gt 2 ]; then { echo "Failing checkins frequently, restarting." ; exit 1; } fi
  20. sleep $SLEEP
  21. done
  22. echo "[netclient] exiting"