summaryrefslogtreecommitdiff
path: root/ext/installfiles/mac/uninstall.sh
blob: 73eac91dccf39471bd9da23534c1104c91966510 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash

export PATH=/bin:/usr/bin:/sbin:/usr/sbin

zthome="/Library/Application Support/ZeroTier/One"
ztapp=`mdfind kMDItemCFBundleIdentifier == 'com.zerotier.ZeroTierOne'`

if [ "$UID" -ne 0 ]; then
	echo "Must be run as root; try: sudo $0"
	exit 1
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
quickAndQuiet=0
if [ "$1" = "-q" ]; then
	quickAndQuiet=1
	echo() { :; }
fi

echo

if [ $quickAndQuiet -eq 0 ]; then  
	echo "This will uninstall ZeroTier One, hit CTRL+C to abort."
	echo "Waiting 5 seconds..."
	sleep 5
fi

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 "$zthome/tap.kext" >>/dev/null 2>&1

echo "Erasing GUI app (if installed)..."
if [ -d "$ztapp" ]; then
	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
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 "you wish to re-use the address of this node, as it cannot be regenerated."

echo

exit 0