From a23eca14e62027924d5dcb6bb00c13b5e676b1bd Mon Sep 17 00:00:00 2001 From: Greg Hart <19595192+innowintay@users.noreply.github.com> Date: Fri, 9 Apr 2021 21:34:16 -0400 Subject: [PATCH] Allow for on-prem JAMF users --- DeploymentScripts/Mac/JAMF_silentinstall.sh | 27 +++++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/DeploymentScripts/Mac/JAMF_silentinstall.sh b/DeploymentScripts/Mac/JAMF_silentinstall.sh index 9816310..b2a968b 100644 --- a/DeploymentScripts/Mac/JAMF_silentinstall.sh +++ b/DeploymentScripts/Mac/JAMF_silentinstall.sh @@ -7,15 +7,25 @@ groupid="$4" grouptoken="$5" email="$6" #If email is entered in parameters, script will skip over using JAMF API, make sure related password is entered as well password="$7" -JAMF_domain="$8" -# The script needs access to the JAMF Pro API to gather related the related email for a given user +# The script needs access to the JAMF Pro API to gather related the related email for a given user # Account just needs to have Users - Read permissions # You can configure a temp account for this in the "Jamf Pro User Accounts & Groups" section of your console +JAMF_url="$8" JAMF_username="$9" JAMF_password="${10}" ################ FUNCTIONS ######################### +function url_protocol_check { + http_regex='https?:\/\/.*' + if [[ "${1}" =~ $http_regex ]]; + then + echo "${1}"|sed -E 's/https?:\/\///g' + else + echo "${1}" + fi +} + function updateBackblaze { return=$(sudo /Volumes/Backblaze\ Installer/Backblaze\ Installer.app/Contents/MacOS/bzinstall_mate -upgrade bzdiy) } @@ -44,7 +54,8 @@ function emailValidation { function jamfAPI { echo "Making GET request to Classic JAMF API" - response=$(curl -s "https://$JAMF_domain.jamfcloud.com/JSSResource/users/name/$username" -u "$JAMF_username:$JAMF_password") + JAMF_fqdn=$(url_protocol_check "${JAMF_url}") + response=$(curl -s "https://$JAMF_fqdn/JSSResource/users/name/$username" -u "$JAMF_username:$JAMF_password") email=$(echo $response | /usr/bin/awk -F'|' '{print $2}') emailValidation @@ -71,8 +82,8 @@ function killSyspref { } function setDirectory { - if [ -n "$3" ] - then + if [ -n "$3" ] + then cd /Users/"$3" || { echo "Failed to cd to user directory"; exit 1; } fi } @@ -84,7 +95,7 @@ function downloadBackblaze { function mountBackblaze { echo "Mounting Installer..." - hdiutil attach -quiet -nobrowse install_backblaze.dmg + hdiutil attach -quiet -nobrowse install_backblaze.dmg } ################################################### @@ -95,8 +106,8 @@ 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" ; +#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