monitor_entrypoint.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. netcon_wait_time=25 # wait for test container to come online
  9. app_timeout_time=15 # app-specific timeout
  10. file_path=/opt/results/ # test result output file path (fs shared between host and containers)
  11. file_base="$test_name".txt # test result output file
  12. fail=FAIL. # appended to result file in event of failure
  13. ok=OK. # appended to result file in event of success
  14. tmp_ext=.tmp # temporary filetype used for sharing test data between containers
  15. address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
  16. bigfile_name=bigfile # large, random test transfer file
  17. rx_md5sumfile="$file_path"rx_"$bigfile_name"_md5sum"$tmp_ext"
  18. tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
  19. # --- Network Config ---
  20. echo '*** ZeroTier Network Containers Test Monitor'
  21. chown -R daemon /var/lib/zerotier-one
  22. chgrp -R daemon /var/lib/zerotier-one
  23. su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
  24. virtip4=""
  25. while [ -z "$virtip4" ]; do
  26. sleep 0.2
  27. virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
  28. done
  29. echo '*** Starting Test...'
  30. echo '*** Up and running at' $virtip4 ' on network: ' $nwid
  31. echo '*** Sleeping for (' "$netcon_wait_time" 's ) while we wait for the Network Container to come online...'
  32. sleep "$netcon_wait_time"s
  33. ncvirtip=$(<$address_file)
  34. # --- Test section ---
  35. echo '*** Copying file to intercepted server at' $ncvirtip
  36. touch "$bigfile_name"
  37. # Check md5
  38. md5sum < "$bigfile_name" > "$rx_md5sumfile"
  39. tx_md5sum=$(<$tx_md5sumfile)
  40. # ...