netcon_entrypoint.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. bigfile_name=bigfile
  13. bigfile_size=10M # size of file we want to use for the test
  14. tx_md5sumfile="$file_path"tx_"$bigfile_name"_md5sum"$tmp_ext"
  15. # --- Network Config ---
  16. echo '*** ZeroTier Network Containers Test: ' "$test_name"
  17. chown -R daemon /var/lib/zerotier-one
  18. chgrp -R daemon /var/lib/zerotier-one
  19. su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
  20. echo '*** Waiting for initial identity generation...'
  21. while [ ! -s /var/lib/zerotier-one/identity.secret ]; do
  22. sleep 0.2
  23. done
  24. echo '*** Waiting for network config...'
  25. virtip4=""
  26. while [ ! -s /var/lib/zerotier-one/networks.d/"$nwconf" ]; do
  27. sleep 0.2
  28. done
  29. while [ -z "$virtip4" ]; do
  30. sleep 0.2
  31. virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
  32. done
  33. echo '*** Up and running at' $virtip4 ' on network: ' $nwid
  34. echo '*** Writing address to ' "$address_file"
  35. echo $virtip4 > "$address_file"
  36. # --- Test section ---
  37. # Generate large random file for transfer test, share md5sum for monitor container to check
  38. echo '*** Generating ' "$bigfile_size" ' file'
  39. dd if=/dev/urandom of=/var/www/html/"$bigfile_name" bs="$bigfile_size" count=1
  40. #md5sum /var/www/html/"$bigfile_name" >> "$tx_md5sumfile"
  41. md5sum < /var/www/html/"$bigfile_name" >> "$tx_md5sumfile"
  42. echo '*** Wrote MD5 sum to ' "$tx_md5sumfile"
  43. echo '*** Starting application...'
  44. sleep 0.5
  45. rm -rf /run/httpd/* /tmp/httpd*
  46. zerotier-intercept /usr/sbin/httpd -X