entrypoint.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
  3. echo '***'
  4. echo '*** ZeroTier Network Containers Preview'
  5. echo '*** https://www.zerotier.com/'
  6. echo '***'
  7. echo '*** Starting ZeroTier network container host...'
  8. chown -R daemon /var/lib/zerotier-one
  9. chgrp -R daemon /var/lib/zerotier-one
  10. su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
  11. #/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1
  12. echo '*** Waiting for initial identity generation...'
  13. while [ ! -s /var/lib/zerotier-one/identity.secret ]; do
  14. sleep 0.2
  15. done
  16. # HACK: permissions model nonexistent yet... make sure httpd's can talk to this...
  17. chmod 0777 /tmp/.zt*
  18. echo '*** Waiting for network config...'
  19. virtip4=""
  20. while [ ! -s /var/lib/zerotier-one/networks.d/8056c2e21c000001.conf ]; do
  21. sleep 0.2
  22. done
  23. while [ -z "$virtip4" ]; do
  24. sleep 0.2
  25. virtip4=`/zerotier-cli listnetworks | grep -F 8056c2e21c000001 | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
  26. done
  27. echo '*** Starting Apache...'
  28. echo '***'
  29. echo '*** Up and running at' $virtip4 '-- join network 8056c2e21c000001 and try:'
  30. echo '*** > ping' $virtip4
  31. echo -n '*** > curl http://'
  32. echo -n $virtip4
  33. echo '/'
  34. echo '***'
  35. echo "*** Be (a little) patient. It'll probably take 1-2 minutes to be reachable."
  36. echo '***'
  37. echo '*** Follow https://www.zerotier.com/blog for news and release announcements!'
  38. echo '***'
  39. #while /bin/true; do
  40. # sleep 1000000
  41. #done
  42. sleep 0.5
  43. rm -rf /run/httpd/* /tmp/httpd*
  44. intercept /usr/sbin/httpd -D FOREGROUND >>/tmp/apache.out 2>&1