netcon_entrypoint.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. virtip4=""
  18. while [ -z "$virtip4" ]; do
  19. sleep 0.2
  20. virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
  21. dev=`/zerotier-cli listnetworks | grep -F "" | cut -d ' ' -f 8 | cut -d "_" -f 2 | sed "s/^<dev>//" | tr '\n' '\0'`
  22. done
  23. echo '*** Up and running at' $virtip4 ' on network: ' $nwid
  24. echo '*** Writing address to ' "$address_file"
  25. echo $virtip4 > "$address_file"
  26. export ZT_NC_NWID=$dev
  27. # --- Test section ---
  28. echo '*** Starting application...'
  29. sleep 0.5
  30. zerotier-intercept node httpserver.js