launch.sh 1.1 KB

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. zthome="/Library/Application Support/ZeroTier/One"
  3. export PATH="/bin:/usr/bin:/sbin:/usr/sbin:$zthome"
  4. ztapp=`mdfind kMDItemCFBundleIdentifier == 'com.zerotier.ZeroTierOne' | grep -E '.+[.]app$' | sort | head -n 1`
  5. # Clean all other stuff off the system if the user has trashed the .app
  6. if [ -z "$ztapp" -o ! -d "$ztapp" ]; then
  7. # Double-check default location just in case there is some issue with mdfind
  8. ztapp="/Applications/ZeroTier One.app"
  9. if [ ! -d "$ztapp" ]; then
  10. if [ -e "$zthome/uninstall.sh" ]; then
  11. cd "$zthome"
  12. nohup "$zthome/uninstall.sh" >>/tmp/ZeroTierOneUninstall.log 2>&1 &
  13. disown %1
  14. exit 0
  15. fi
  16. fi
  17. fi
  18. # Create the app deletion notification symlink if it does
  19. # not already exist.
  20. shutdownIfUnreadablePointsTo=`readlink "$zthome/shutdownIfUnreadable"`
  21. if [ -z "$shutdownIfUnreadablePointsTo" -o "$shutdownIfUnreadablePointsTo" != "$ztapp/Contents/Info.plist" ]; then
  22. rm -f "$zthome/shutdownIfUnreadable"
  23. ln -sf "$ztapp/Contents/Info.plist" "$zthome/shutdownIfUnreadable"
  24. fi
  25. # Launch ZeroTier One (not as daemon... launchd monitors it)
  26. exec zerotier-one