From 50ef47cf0acdd7e020fb60543a72b7ba679bfd0b Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Fri, 13 Dec 2013 16:15:42 -0800 Subject: [PATCH] Mac launchd item and launcher script, uninstaller work. --- ext/installfiles/mac/check_for_updates.sh | 2 -- ext/installfiles/mac/com.zerotier.one.plist | 22 +++++++++++++++++++ ext/installfiles/mac/launch.sh | 24 +++++++++++++++++++++ ext/installfiles/mac/uninstall.sh | 12 ++++++++--- 4 files changed, 55 insertions(+), 5 deletions(-) delete mode 100755 ext/installfiles/mac/check_for_updates.sh create mode 100644 ext/installfiles/mac/com.zerotier.one.plist create mode 100755 ext/installfiles/mac/launch.sh diff --git a/ext/installfiles/mac/check_for_updates.sh b/ext/installfiles/mac/check_for_updates.sh deleted file mode 100755 index 05a7907cf..000000000 --- a/ext/installfiles/mac/check_for_updates.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash - diff --git a/ext/installfiles/mac/com.zerotier.one.plist b/ext/installfiles/mac/com.zerotier.one.plist new file mode 100644 index 000000000..e3c227d69 --- /dev/null +++ b/ext/installfiles/mac/com.zerotier.one.plist @@ -0,0 +1,22 @@ + + + + + Label + com.zerotier.one + UserName + root + ProgramArguments + + /Library/Application Support/ZeroTier/One/launch.sh + + WorkingDirectory + /Library/Application Support/ZeroTier/One + StandardOutPath + /dev/null + StandardErrorPath + /dev/null + KeepAlive + + + diff --git a/ext/installfiles/mac/launch.sh b/ext/installfiles/mac/launch.sh new file mode 100755 index 000000000..5128fdd94 --- /dev/null +++ b/ext/installfiles/mac/launch.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +zthome="/Library/Application Support/ZeroTier/One" +ztapp="/Applications/ZeroTier One.app" + +export PATH="/bin:/usr/bin:/sbin:/usr/sbin:$zthome" + +# Uninstall if the .app has been thrown away +if [ ! -d "$ztapp" ]; then + if [ -e "$zthome/uninstall.sh" ]; then + exec "$zthome/uninstall.sh" + exit + fi +fi + +# Create the app deletion notification symlink if it does +# not already exist. +if [ ! -L "$zthome/shutdownIfUnreadable" ]; then + rm -f "$zthome/shutdownIfUnreadable" + ln -sf "$ztapp/Contents/Info.plist" "$zthome/shutdownIfUnreadable" +fi + +# Launch ZeroTier One (not as daemon... launchd monitors it) +exec zerotier-one diff --git a/ext/installfiles/mac/uninstall.sh b/ext/installfiles/mac/uninstall.sh index 4fa26d00b..b9563a112 100755 --- a/ext/installfiles/mac/uninstall.sh +++ b/ext/installfiles/mac/uninstall.sh @@ -2,6 +2,9 @@ export PATH=/bin:/usr/bin:/sbin:/usr/sbin +ztpath="/Library/Application Support/ZeroTier/One" +ztapp="/Applications/ZeroTier One.app" + if [ "$UID" -ne 0 ]; then echo "Must be run as root; try: sudo $0" exit 1 @@ -13,19 +16,22 @@ echo "This will uninstall ZeroTier One, hit CTRL+C to abort." echo "Waiting 5 seconds..." sleep 5 -ztpath="/Library/Application Support/ZeroTier/One" +echo "Unloading and removing LaunchDaemons item..." +launchctl unload /Library/LaunchDaemons/com.zerotier.one.plist +rm -f /Library/LaunchDaemons/com.zerotier.one.plist echo "Killing any running zerotier-one service..." killall -TERM zerotier-one >>/dev/null 2>&1 sleep 3 killall -KILL zerotier-one >>/dev/null 2>&1 +sleep 1 echo "Unloading kernel extension..." kextunload "$ztpath/tap.kext" -echo "Erasing binary and support files..." +echo "Erasing UI app, binary, and support files..." cd $ztpath -rm -rfv zerotier-one *.persist authtoken.secret identity.public *.log *.pid *.kext +rm -rfv "$ztapp" zerotier-one *.persist authtoken.secret identity.public *.log *.pid *.kext *.sh echo "Done." echo