netcon_entrypoint.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/bash
  2. export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
  3. # --- Test Parameters ---
  4. test_namefile=$(ls *.name)
  5. test_name="${test_namefile%.*}" # test network id
  6. nwconf=$(ls *.conf) # blank test network config file
  7. nwid="${nwconf%.*}" # test network id
  8. file_path=/opt/results/ # test result output file path (fs shared between host and containers)
  9. file_base="$test_name".txt # test result output file
  10. tmp_ext=.tmp # temporary filetype used for sharing test data between containers
  11. address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
  12. # --- Network Config ---
  13. echo '*** ZeroTier Network Containers Test: ' "$test_name"
  14. chown -R daemon /var/lib/zerotier-one
  15. chgrp -R daemon /var/lib/zerotier-one
  16. su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
  17. echo '*** Waiting for initial identity generation...'
  18. while [ ! -s /var/lib/zerotier-one/identity.secret ]; do
  19. sleep 0.2
  20. done
  21. echo '*** Waiting for network config...'
  22. virtip4=""
  23. while [ ! -s /var/lib/zerotier-one/networks.d/"$nwconf" ]; do
  24. sleep 0.2
  25. done
  26. while [ -z "$virtip4" ]; do
  27. sleep 0.2
  28. virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
  29. done
  30. echo '*** Up and running at' $virtip4 ' on network: ' $nwid
  31. echo '*** Writing address to ' "$address_file"
  32. echo $virtip4 > "$address_file"
  33. # --- Test section ---
  34. echo '*** Starting application...'
  35. sleep 0.5
  36. zerotier-intercept node httpserver.js