-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackblaze_uninstall
56 lines (43 loc) · 2.24 KB
/
backblaze_uninstall
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
#!/bin/zsh
#Script to silently uninstall backblaze using inbuilt executables.
#You will need to have Backblaze Application installed on your machine in order for this script to work.
#Author: Anuj Chokshi
# Determine logged in user
user=$(/usr/sbin/scutil <<< "show State:/Users/ConsoleUser" | /usr/bin/awk '/Name :/ && ! /loginwindow/ { print $3 }')
# LaunchAgent Path
launch_agent_name="com.backblaze.bzbmenu"
launch_agent_plist="/Library/LaunchAgents/com.backblaze.bzbmenu.plist"
#Check if the Backblaze preference folder exists. If not, terminate the operation.
if [ -d "/Library/Backblaze.bzpkg" ] ; then
echo "Directory /Library/Backblaze.bzpkg/ exists.Continuing with uninstallation."
else
echo "Backblaze Preference file not found."
exit 1
fi
#Pause all on-going backups.
/Library/Backblaze.bzpkg/bztransmit -pausebackup
#Check and unload bzbmenu launchagent for all users and delete it.
for name in $(/usr/bin/dscl /Local/Default list /Users UniqueID | /usr/bin/awk '$2 > 500 {print $1}'); do
# Determine home directory of user
home_dir="$(/usr/bin/dscl /Local/Default read /Users/"$name" NFSHomeDirectory | /usr/bin/awk '{print $2}')"
uid="$(/usr/bin/id -u "$user")"
# Unload LaunchAgent if running
if [[ $(/bin/launchctl print user/"$uid" | /usr/bin/grep "$launch_agent_name") ]]; then
/bin/launchctl bootout gui/"$uid" "$launch_agent_plist" >/dev/null 2>&1
fi
/usr/bin/sudo -u "$name" /bin/rm -f "$3"/"$home_dir"/Library/LaunchAgents/com.backblaze.bzbmenu.plist
done
#Execute inbuilt executable file to shutdown bzserve process.
/Library/Backblaze.bzpkg/UninstallBackblaze.app/Contents/MacOS/shutdown_bzserve
#Execute inbuilt executable file to delete additional files for backblaze.
/Library/Backblaze.bzpkg/UninstallBackblaze.app/Contents/MacOS/delete_file
#Execute inbuilt executable file to shutdown bzbmenu process.
/Library/Backblaze.bzpkg/UninstallBackblaze.app/Contents/MacOS/shutdown_bzbmenu
#kill system preferences
killall -KILL System\ Preferences >/dev/null 2>&1
#Remove Backblaze Systems Preference pane.
/bin/rm -rf /Library/PreferencePanes/BackblazeBackup.prefPane
#Remove Backblaze Preference directory from Systems Library.
/bin/rm -rf /Library/Backblaze.bzpkg
#Remove Backblaze Application.
/bin/rm -rf /Applications/Backblaze.app