netcon_entrypoint.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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-netcon-service -d -U -p9993 >>/tmp/zerotier-netcon-service.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. # --- Test section ---
  27. echo '*** Starting application...'
  28. sleep 0.5
  29. export ZT_NC_NETWORK=/var/lib/zerotier-one/nc_"$dev"
  30. export LD_PRELOAD=./libzerotierintercept.so
  31. /usr/bin/redis-server --port 6379