postinst.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
  3. OSX_RELEASE=`sw_vers -productVersion | cut -d . -f 1,2`
  4. launchctl unload /Library/LaunchDaemons/com.zerotier.one.plist >>/dev/null 2>&1
  5. sleep 1
  6. cd "/Library/Application Support/ZeroTier/One"
  7. if [ "$OSX_RELEASE" = "10.7" ]; then
  8. # OSX 10.7 cannot use the new tap driver since the new way of kext signing
  9. # is not backward compatible. Pull the old one for 10.7 users and replace.
  10. # We use https to fetch and check hash as an extra added measure.
  11. rm -f tap.kext.10_7.tar.gz
  12. curl -s https://download.zerotier.com/tap.kext.10_7.tar.gz >tap.kext.10_7.tar.gz
  13. if [ -s tap.kext.10_7.tar.gz -a "`shasum -a 256 tap.kext.10_7.tar.gz | cut -d ' ' -f 1`" = "e133d4832cef571621d3618f417381b44f51a76ed625089fb4e545e65d3ef2a9" ]; then
  14. rm -rf tap.kext
  15. tar -xzf tap.kext.10_7.tar.gz
  16. fi
  17. rm -f tap.kext.10_7.tar.gz
  18. fi
  19. rm -rf node.log node.log.old root-topology shutdownIfUnreadable autoupdate.log updates.d
  20. chown -R 0 tap.kext
  21. chgrp -R 0 tap.kext
  22. if [ ! -f authtoken.secret ]; then
  23. head -c 4096 /dev/urandom | md5 | head -c 24 >authtoken.secret
  24. chown 0 authtoken.secret
  25. chgrp 0 authtoken.secret
  26. chmod 0600 authtoken.secret
  27. fi
  28. rm -f zerotier-cli zerotier-idtool
  29. ln -sf zerotier-one zerotier-cli
  30. ln -sf zerotier-one zerotier-idtool
  31. mkdir -p /usr/local/bin
  32. cd /usr/local/bin
  33. rm -f zerotier-cli zerotier-idtool
  34. ln -sf "/Library/Application Support/ZeroTier/One/zerotier-one" zerotier-cli
  35. ln -sf "/Library/Application Support/ZeroTier/One/zerotier-one" zerotier-idtool
  36. launchctl load /Library/LaunchDaemons/com.zerotier.one.plist >>/dev/null 2>&1
  37. exit 0