forked from ryangball/nice-updater
-
Notifications
You must be signed in to change notification settings - Fork 7
/
nice_updater_uninstall.sh
executable file
·71 lines (54 loc) · 2.31 KB
/
nice_updater_uninstall.sh
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
64
65
66
67
68
69
70
71
#!/bin/bash
# The main identifier which everything hinges on
identifier="com.grahamrpugh.nice_updater"
# The location of your log, keep in mind that if you nest the log into a folder that does not exist you'll need to mkdir -p the directory as well
log="/Library/Logs/Nice_Updater.log"
###### Variables below this point are not intended to be modified #####
mainDaemonPlist="/Library/LaunchDaemons/${identifier}.plist"
mainOnDemandDaemonPlist="/Library/LaunchDaemons/${identifier}_on_demand.plist"
watchPathsPlist="/Library/Preferences/${identifier}.trigger.plist"
preferenceFileFullPath="/Library/Preferences/${identifier}.prefs.plist"
iconPath="/Library/Scripts/nice_updater_custom_icon.png"
EAFilePath="/Library/Scripts/nice_updater_status.txt"
scriptPath="/Library/Scripts/nice_updater.sh"
uninstallScriptPath="/Library/Scripts/nice_updater_uninstall.sh"
uninstallScriptName=$(basename "$uninstallScriptPath")
writelog() {
DATE=$(date +%Y-%m-%d\ %H:%M:%S)
/bin/echo "${1}"
/bin/echo "$DATE" " $1" >> "$log"
}
finish() {
writelog "======== Finished $uninstallScriptName ========"
exit "$1"
}
writelog " "
writelog "======== Starting $uninstallScriptName ========"
writelog "Stopping NiceUpdater On-Demand LaunchDaemon..."
launchctl unload -w "$mainOnDemandDaemonPlist"
writelog "Stopping NiceUpdater LaunchDaemon..."
launchctl unload -w "$mainDaemonPlist"
writelog "Deleting NiceUpdater LaunchDaemons..."
# Delete the main Daemon plist
[[ -e "$mainOnDemandDaemonPlist" ]] && rm -f "$mainOnDemandDaemonPlist"
# Delete the on_demand Daemon plist
[[ -e "$mainDaemonPlist" ]] && rm -f "$mainDaemonPlist"
writelog "Deleting NiceUpdater Preferences..."
# Delete the main preferences file
[[ -e "$preferenceFileFullPath" ]] && rm -f "$preferenceFileFullPath"
# Delete the watch path preferences file
[[ -e "$watchPathsPlist" ]] && rm -f "$watchPathsPlist"
writelog "Deleting NiceUpdater files..."
# Delete the icon file
[[ -e "$iconPath" ]] && rm -f "$iconPath"
# Delete the status file
[[ -e "$EAFilePath" ]] && rm -f "$iconPath"
# Delete the main preferences file
[[ -e "$scriptPath" ]] && rm -f "$scriptPath"
[[ -e "$uninstallScriptPath" ]] && rm -f "$uninstallScriptPath"
writelog "Forgetting the package..."
# Find any packages and remove them
if pkgutil --pkgs=$identifier ; then
pkgutil --forget $identifier
fi
finish 0