main.sh 752 B

1234567891011121314151617181920212223242526
  1. #!/bin/bash
  2. export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin
  3. if [ ! -c "/dev/net/tun" ]; then
  4. echo 'FATAL: must be docker run with: --device=/dev/net/tun --cap-add=NET_ADMIN'
  5. exit 1
  6. fi
  7. if [ -z "$ZEROTIER_IDENTITY_SECRET" ]; then
  8. echo 'FATAL: ZEROTIER_IDENTITY_SECRET not set -- aborting!'
  9. exit 1
  10. fi
  11. if [ -z "$ZEROTIER_NETWORK" ]; then
  12. echo 'Warning: ZEROTIER_NETWORK not set, you will need to docker exec zerotier-cli to join a network.'
  13. else
  14. # The existence of a .conf will cause the service to "remember" this network
  15. touch /var/lib/zerotier-one/networks.d/$ZEROTIER_NETWORK.conf
  16. fi
  17. rm -f /var/lib/zerotier-one/identity.*
  18. echo "$ZEROTIER_IDENTITY_SECRET" >/var/lib/zerotier-one/identity.secret
  19. /var/lib/zerotier-one/zerotier-one