preinst.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. export PATH=/bin:/usr/bin:/sbin:/usr/sbin
  3. rm -f /tmp/zt1-gui-restart.tmp
  4. for i in `ps axuwww | tr -s ' ' ',' | grep -F '/Applications/ZeroTier,One.app' | grep -F -v grep | cut -d , -f 1,2 | xargs`; do
  5. u=`echo $i | cut -d , -f 1`
  6. p=`echo $i | cut -d , -f 2`
  7. if [ ! -z "$u" -a "0$p" -gt 0 ]; then
  8. kill $p >>/dev/null 2>&1
  9. sleep 0.5
  10. kill -9 $p >>/dev/null 2>&1
  11. echo "$u" >>/tmp/zt1-gui-restart.tmp
  12. fi
  13. done
  14. for i in `ps axuwww | tr -s ' ' ',' | grep -F '/Applications/ZeroTier.app' | grep -F -v grep | cut -d , -f 1,2 | xargs`; do
  15. u=`echo $i | cut -d , -f 1`
  16. p=`echo $i | cut -d , -f 2`
  17. if [ ! -z "$u" -a "0$p" -gt 0 ]; then
  18. kill $p >>/dev/null 2>&1
  19. sleep 0.5
  20. kill -9 $p >>/dev/null 2>&1
  21. echo "$u" >>/tmp/zt1-gui-restart.tmp
  22. fi
  23. done
  24. chmod 0600 /tmp/zt1-gui-restart.tmp
  25. cd "/Applications"
  26. rm -rf "ZeroTier One.app"
  27. rm -rf "ZeroTier.app"
  28. if [ -d '/Library/Application Support/ZeroTier/One' ]; then
  29. cd '/Library/Application Support/ZeroTier/One'
  30. # ensure that file locking doesn't cause issues with replacing the binary
  31. rm -f zerotier-one
  32. rm -f MacEthernetTapAgent
  33. fi
  34. exit 0