uninstall.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. export PATH=/bin:/usr/bin:/sbin:/usr/sbin
  3. zthome="/Library/Application Support/ZeroTier/One"
  4. ztapp="/Applications/ZeroTier One.app"
  5. if [ -z "$ztapp" -o ! -d "$ztapp" ]; then
  6. ztapp=`mdfind kMDItemCFBundleIdentifier == 'com.zerotier.ZeroTierOne' | grep -E '.*ZeroTier One[.]app$' | grep -v -F '/build-' | grep -v -F '/Volumes/ZeroTier' | sort | head -n 1`
  7. fi
  8. if [ "$UID" -ne 0 ]; then
  9. echo "Must be run as root; try: sudo $0"
  10. exit 1
  11. fi
  12. echo "Killing any running zerotier-one service..."
  13. killall -TERM zerotier-one >>/dev/null 2>&1
  14. sleep 3
  15. killall -KILL zerotier-one >>/dev/null 2>&1
  16. sleep 1
  17. echo "Unloading kernel extension..."
  18. kextunload "$zthome/pre10.8/tap.kext" >>/dev/null 2>&1
  19. kextunload "$zthome/tap.kext" >>/dev/null 2>&1
  20. echo "Erasing GUI app (if installed)..."
  21. if [ ! -z "$ztapp" -a -d "$ztapp" -a -f "$ztapp/Contents/Info.plist" ]; then
  22. rm -rf "$ztapp"
  23. fi
  24. echo "Erasing service and support files..."
  25. rm -f /usr/bin/zerotier-cli
  26. rm -f /usr/bin/zerotier-idtool
  27. cd "$zthome"
  28. rm -f zerotier-one *.persist identity.public *.log *.pid *.sh shutdownIfUnreadable
  29. rm -rf pre10.8 tap.kext updates.d networks.d
  30. echo "Removing LaunchDaemons item..."
  31. rm -f /Library/LaunchDaemons/com.zerotier.one.plist
  32. launchctl remove com.zerotier.one
  33. echo "Done."
  34. echo
  35. echo "Your ZeroTier One identity is still in: $zthome"
  36. echo "as identity.secret and can be manually deleted if you wish. Save it if"
  37. echo "you wish to re-use the address of this node, as it cannot be regenerated."
  38. echo
  39. exit 0