netclient.sh 608 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. #Define cleanup
  3. cleanup() {
  4. nets=($(wg show interfaces))
  5. for net in ${nets[@]}; do
  6. echo "deleting interface" $net
  7. ip link del $net
  8. done
  9. }
  10. #Trap SigTerm
  11. trap 'cleanup' SIGTERM
  12. echo "[netclient] joining network"
  13. if [ -z "${SLEEP}" ]; then
  14. SLEEP=10
  15. fi
  16. TOKEN_CMD=""
  17. if [ "$TOKEN" != "" ]; then
  18. TOKEN_CMD="-t $TOKEN"
  19. fi
  20. /root/netclient join $TOKEN_CMD -dnson no -udpholepunch no
  21. if [ $? -ne 0 ]; then { echo "Failed to join, quitting." ; exit 1; } fi
  22. echo "[netclient] Starting netclient daemon"
  23. /root/netclient daemon &
  24. wait $!
  25. echo "[netclient] exiting"