Update mac launcher and uninstaller to use mdfind to locate app.

This commit is contained in:
Adam Ierymenko 2014-01-03 10:26:40 -08:00
parent fb685bcb1d
commit 69c993357d
2 changed files with 30 additions and 16 deletions

View file

@ -1,11 +1,13 @@
#!/bin/bash #!/bin/bash
zthome="/Library/Application Support/ZeroTier/One" zthome="/Library/Application Support/ZeroTier/One"
ztapp="/Applications/ZeroTier One.app"
export PATH="/bin:/usr/bin:/sbin:/usr/sbin:$zthome" export PATH="/bin:/usr/bin:/sbin:/usr/sbin:$zthome"
ztapp=`mdfind kMDItemCFBundleIdentifier == 'com.zerotier.ZeroTierOne'`
# Uninstall if the .app has been thrown away # Clean all other stuff off the system if the user has trashed the .app
if [ -z "$ztapp" -o ! -d "$ztapp" ]; then
# Double-check default location just in case there is some issue with mdfind
ztapp="/Applications/ZeroTier One.app"
if [ ! -d "$ztapp" ]; then if [ ! -d "$ztapp" ]; then
if [ -e "$zthome/uninstall.sh" ]; then if [ -e "$zthome/uninstall.sh" ]; then
cd "$zthome" cd "$zthome"
@ -13,10 +15,12 @@ if [ ! -d "$ztapp" ]; then
exit exit
fi fi
fi fi
fi
# Create the app deletion notification symlink if it does # Create the app deletion notification symlink if it does
# not already exist. # not already exist.
if [ ! -L "$zthome/shutdownIfUnreadable" ]; then shutdownIfUnreadablePointsTo=`readlink "$zthome/shutdownIfUnreadable"`
if [ -z "$shutdownIfUnreadablePointsTo" -o "$shutdownIfUnreadablePointsTo" != "$ztapp/Contents/Info.plist" ]; then
rm -f "$zthome/shutdownIfUnreadable" rm -f "$zthome/shutdownIfUnreadable"
ln -sf "$ztapp/Contents/Info.plist" "$zthome/shutdownIfUnreadable" ln -sf "$ztapp/Contents/Info.plist" "$zthome/shutdownIfUnreadable"
fi fi

View file

@ -2,14 +2,19 @@
export PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH=/bin:/usr/bin:/sbin:/usr/sbin
ztpath="/Library/Application Support/ZeroTier/One" zthome="/Library/Application Support/ZeroTier/One"
ztapp="/Applications/ZeroTier One.app" ztapp=`mdfind kMDItemCFBundleIdentifier == 'com.zerotier.ZeroTierOne'`
if [ "$UID" -ne 0 ]; then if [ "$UID" -ne 0 ]; then
echo "Must be run as root; try: sudo $0" echo "Must be run as root; try: sudo $0"
exit 1 exit 1
fi fi
# Try default location if something's up with mdfind
if [ ! -d "$ztapp" ]; then
ztapp="/Applications/ZeroTier One.app"
fi
# Run with -q to be quieter and run without delay # Run with -q to be quieter and run without delay
quickAndQuiet=0 quickAndQuiet=0
if [ "$1" = "-q" ]; then if [ "$1" = "-q" ]; then
@ -36,15 +41,20 @@ killall -KILL zerotier-one >>/dev/null 2>&1
sleep 1 sleep 1
echo "Unloading kernel extension..." echo "Unloading kernel extension..."
kextunload "$ztpath/tap.kext" >>/dev/null 2>&1 kextunload "$zthome/tap.kext" >>/dev/null 2>&1
echo "Erasing UI app, binary, and support files..." echo "Erasing GUI app (if installed)..."
cd "$ztpath" if [ -d "$ztapp" ]; then
rm -rfv "$ztapp" zerotier-one *.persist authtoken.secret identity.public *.log *.pid *.kext *.sh networks.d updates.d shutdownIfUnreadable rm -rfv "$ztapp"
fi
echo "Erasing service and support files..."
cd "$zthome"
rm -rfv zerotier-one *.persist authtoken.secret identity.public *.log *.pid *.kext *.sh networks.d updates.d shutdownIfUnreadable
echo "Done." echo "Done."
echo echo
echo "Your ZeroTier One identity is still preserved in $ztpath" echo "Your ZeroTier One identity is still in: $zthome"
echo "as identity.secret and can be manually deleted if you wish. Save it if" echo "as identity.secret and can be manually deleted if you wish. Save it if"
echo "you wish to re-use the address of this node, as it cannot be regenerated." echo "you wish to re-use the address of this node, as it cannot be regenerated."