Created
May 10, 2022 20:00
-
-
Save cdoggyd/fb4da04d1cee6eb005e58ef7ee4229c4 to your computer and use it in GitHub Desktop.
Backblaze_silentinstall.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Reference: https://help.backblaze.com/hc/en-us/articles/115002603173-Backblaze-Mass-Silent-Install-with-Jamf-Mac- | |
# The following parameters are pulled directly from the "Parameter Values" section of your Backblaze deployment policy. | |
# Please make sure they are filled out respectively prior to your push | |
username="%UserId%" | |
groupid="FILL IN YOUR OWN" | |
grouptoken="FILL IN YOUR OWN" | |
email="%Email%" | |
password="FILL IN YOUR OWN" | |
################ FUNCTIONS ######################### | |
function updateBackblaze { | |
return=$(/Volumes/Backblaze\ Installer/Backblaze\ Installer.app/Contents/MacOS/bzinstall_mate -upgrade bzdiy) | |
} | |
function signinBackblaze { | |
return=$(/Volumes/Backblaze\ Installer/Backblaze\ Installer.app/Contents/MacOS/bzinstall_mate -nogui -signinaccount $email $password $groupid $grouptoken) | |
} | |
function createaccountBackblaze { | |
return=$(/Volumes/Backblaze\ Installer/Backblaze\ Installer.app/Contents/MacOS/bzinstall_mate -nogui -createaccount $email $password $groupid $grouptoken) | |
} | |
function successExit { | |
echo "Unmounting Installer..." | |
diskutil unmount /Volumes/Backblaze\ Installer | |
echo "Cleaning up..." | |
rm install_backblaze.dmg | |
exit 0 | |
} | |
function failureExit { | |
echo "Unmounting Installer..." | |
diskutil unmount /Volumes/Backblaze\ Installer | |
echo "Cleaning up..." | |
rm -f install_backblaze.dmg | |
exit 1 | |
} | |
function killSyspref { | |
killall -KILL System\ Preferences > /dev/null 2>&1 | |
} | |
function setDirectory { | |
cd /tmp | |
} | |
function downloadBackblaze { | |
echo "Downloading latest backblaze client..." | |
curl -s -O https://secure.backblaze.com/mac/install_backblaze.dmg | |
} | |
function mountBackblaze { | |
echo "Mounting Installer..." | |
hdiutil attach -quiet -nobrowse install_backblaze.dmg | |
} | |
################################################### | |
setDirectory "$@" | |
downloadBackblaze | |
mountBackblaze | |
#Kill System Preferences process to prevent related BZERROR | |
killSyspref | |
#Check to see if Backblaze is installed already, if so update it. Else continue as planned. | |
if open -Ra "Backblaze" ; | |
then | |
echo "Backblaze already installed, attempting to update" | |
updateBackblaze | |
if [ "$return" == "BZERROR:1001" ] | |
then | |
echo Backblaze successfully updated | |
successExit | |
else | |
#Try upgrade again incase there was a file lock on the mounted dmg causing errors | |
updateBackblaze | |
if [ "$return" == "BZERROR:1001" ] | |
then | |
echo Backblaze successfully updated | |
successExit | |
else | |
echo "Backblaze was already installed but failed to update" | |
failureExit | |
fi | |
fi | |
else | |
echo "Confirmed Backblaze isnt installed already, continuing with deployment..." | |
fi | |
#If email wasnt passed in from parameters, fail | |
if [ "$email" == "" ] | |
then | |
echo "Email not detected" | |
fi | |
echo "Trying to sign in account" | |
signinBackblaze | |
if [ "$return" == "BZERROR:1001" ] | |
then | |
echo Backblaze installed, $email already had an account with Backblaze | |
successExit | |
else | |
echo "Account doesnt exist, trying to create account" | |
createaccountBackblaze | |
if [ "$return" == "BZERROR:1001" ] | |
then | |
echo Backblaze installed, account created and licensed to $email | |
successExit | |
else | |
echo "Create account failed, trying signing in account again" | |
signinBackblaze | |
if [ "$return" == "BZERROR:1001" ] | |
then | |
echo Backblaze installed, $email already had an account with Backblaze | |
successExit | |
else | |
echo Failed to install Backblaze, errorcode: $return | |
failureExit | |
fi | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment