diff --git a/services/Framework-Fixer/Framework-Fixer.sh b/services/Framework-Fixer/Framework-Fixer.sh old mode 100644 new mode 100755 index 8d049fd..7dbc61f --- a/services/Framework-Fixer/Framework-Fixer.sh +++ b/services/Framework-Fixer/Framework-Fixer.sh @@ -48,7 +48,7 @@ $( date '+%Y-%m-%d %H:%M:%S') INFO: Checking if swiftDialog is installed" >> "${log_file}" if [[ -e "${dialog_path}" ]] then - echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: swiftDialog i=s already installed" >> "${log_file}" + echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: swiftDialog is already installed" >> "${log_file}" else echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: swiftDialog not installed! Please install swiftDialog." >> "${log_file}" osascript <<'EOF' @@ -77,18 +77,18 @@ check_response() { if [[ "${http_code}" =~ ^(200|201|202|204)$ ]] then - echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Command successfully sent: HTTP code: ${http_code}" >> "${log_file}" + echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Command successfully sent: HTTP code: ${http_code}" >> "${log_file}" else - echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: Command failed with HTTP error ${http_code}" >> "${log_file}" - case "${http_code}" in - 400) echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: Bad Request" >> "${log_file}" ;; - 401) echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: Unauthorized – check your credentials." >> "${log_file}" ;; - 403) echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: Forbidden – Insufficient privileges." >> "${log_file}" ;; - 404) echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: Not Found – resource does not exist." >> "${log_file}" ;; - 409) echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: Conflict – resource may already exist." >> "${log_file}" ;; - 500) echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: Server Error – try again later." >> "${log_file}" ;; - *) echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: Unexpected HTTP response: ${http_code}" >> "${log_file}" ;; - esac + echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: Command failed with HTTP error ${http_code}" >> "${log_file}" + case "${http_code}" in + 400) echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: Bad Request" >> "${log_file}" ;; + 401) echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: Unauthorized - check your credentials." >> "${log_file}" ;; + 403) echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: Forbidden - Insufficient privileges." >> "${log_file}" ;; + 404) echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: Not Found - resource does not exist." >> "${log_file}" ;; + 409) echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: Conflict - resource may already exist." >> "${log_file}" ;; + 500) echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: Server Error - try again later." >> "${log_file}" ;; + *) echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: Unexpected HTTP response: ${http_code}" >> "${log_file}" ;; + esac fi echo "${http_code}" } @@ -100,28 +100,32 @@ check_response() { # Prompt to choose Authentication Method auth_method_prompt() { echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Asking to select an authentication method" >> "${log_file}" - - auth_method=$("${dialog_path}" \ - --title "Framework Fixer" \ - --message 'Welcome!\n\nPlease select a method to authenticate to Jamf Pro. Click on "Required Privileges" for more information.' \ - --radio \ - --selecttitle "Please select an option",radio --selectvalues "User Account & Password, API Client & Secret" \ - --icon "${icon}" \ - --alignment "left" \ - --button2 \ - --messagefont "${message_font}" \ - --titlefont "${title_font}" \ - --infobuttontext "Required Privileges" \ - --infobuttonaction "https://github.com//jamf/scripts/refs/heads/main/services/Framework-Fixer?tab=readme-ov-file#requirements" \ - --small) - if [[ $? -ne 0 ]] + + if ! auth_method=$( + "${dialog_path}" \ + --title "Framework Fixer" \ + --message 'Welcome! + +Please select a method to authenticate to Jamf Pro. Click on "Required Privileges" for more information.' \ + --radio \ + --selecttitle "Please select an option",radio \ + --selectvalues "User Account & Password, API Client & Secret" \ + --icon "${icon}" \ + --alignment "left" \ + --button2 \ + --messagefont "${message_font}" \ + --titlefont "${title_font}" \ + --infobuttontext "Required Privileges" \ + --infobuttonaction "https://github.com/Sdelsaz/Framework-Fixer?tab=readme-ov-file#requirements" \ + --small + ) then echo "$(date '+%Y-%m-%d %H:%M:%S') WARNING: User Cancelled" >> "${log_file}" invalidate_token exit 0 fi - auth_selection=$(echo "${auth_method}" | awk -F '"' '{print $4}') - if [[ "${auth_selection}" == *"User Account & Password"* ]] + auth_selection=$(echo "${auth_method}" | grep "\"Please select an option\" : " | awk -F '"' '{print $4}') + if [[ ${auth_selection} == "User Account & Password" ]] then echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Selected authentication method: User Account & Password" >> "${log_file}" username_label="User Name" @@ -138,20 +142,21 @@ auth_method_prompt() { # Prompt for User Account and Password credential_prompt() { echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Prompting for credentials and server URL" >> "${log_file}" - server_details=$("${dialog_path}" \ - --title "Framework Fixer" \ - --message "Please enter your Jamf Pro details below:" \ - --textfield "Jamf Pro URL","required" : true \ - --textfield "${username_label}",required : true \ - --textfield "${password_label}","secure : true,required : true" \ - --icon "${icon}" \ - --alignment "left" \ - --small \ - --button2 \ - --messagefont "${message_font}" \ - --titlefont "${title_font}" \ - --json) - if [[ $? == 0 ]] + if server_details=$( + "${dialog_path}" \ + --title "Framework Fixer" \ + --message "Please enter your Jamf Pro details below:" \ + --textfield "Jamf Pro URL, required" \ + --textfield "${username_label}, required" \ + --textfield "${password_label}, secure, required" \ + --icon "${icon}" \ + --alignment "left" \ + --small \ + --button2 \ + --messagefont "${message_font}" \ + --titlefont "${title_font}" \ + --json + ) then jamf_pro_url=$(echo "${server_details}" | "${plutil_path}" -extract "Jamf Pro URL" xml1 -o - - | xmllint --xpath "string(//string)" -) username=$(echo "${server_details}" | "${plutil_path}" -extract "${username_label}" xml1 -o - - | xmllint --xpath "string(//string)" -) @@ -169,40 +174,43 @@ credential_prompt() { # Prompt explaining there was an issue with the server details/credentials invalid_credentials_prompt() { "${dialog_path}" \ - --title "Framework Fixer" \ - --message "Oops! We were unable to validate the provided URL or credentials. Please make sure that the server is reachable and that the server URL and credentials are correct." \ - --icon "${icon}" \ - --overlayicon "caution" \ - --alignment "left" \ - --small \ - --messagefont "${message_font}" \ - --titlefont "${title_font}" \ - --button1text "OK" + --title "Framework Fixer" \ + --message "Oops! We were unable to validate the provided URL or credentials. Please make sure that the server is reachable and that the server URL and credentials are correct." \ + --icon "${icon}" \ + --overlayicon "caution" \ + --alignment "left" \ + --small \ + --messagefont "${message_font}" \ + --titlefont "${title_font}" \ + --button1text "OK" } # Prompt to choose new or existing group group_option_prompt() { echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Prompting to choose between new group or existing group" >> "${log_file}" - group_options=$("${dialog_path}" \ - --title "Framework Fixer" \ - --message "Would you like to create a Smart Computer Group to redeploy the Jamf Management Framework to?" \ - --radio "group_selection" \ - --selecttitle "Please select an option",radio --selectvalues "I already have a Smart Computer Group, Please create a Smart Computer Group" \ - --icon "${icon}" \ - --alignment "left" \ - --button2 \ - --messagefont "${message_font}" \ - --titlefont "${title_font}" \ - --small) - if [[ $? == 0 ]] + if group_options=$( + "${dialog_path}" \ + --title "Framework Fixer" \ + --message "Would you like to create a Smart Computer Group to redeploy the Jamf Management Framework to?" \ + --radio "group_selection" \ + --selecttitle "Please select an option",radio \ + --selectvalues "I already have a Smart Computer Group, Please create a Smart Computer Group" \ + --icon "${icon}" \ + --alignment "left" \ + --button2 \ + --messagefont "${message_font}" \ + --titlefont "${title_font}" \ + --small + ) then - group_selection=$(echo "${group_options}" | awk -F '"' '{print $4}') + group_selection=$(echo "${group_options}" | grep "\"Please select an option\" : " | awk -F '"' '{print $4}') else echo "$(date '+%Y-%m-%d %H:%M:%S') WARNING: User Cancelled" >> "${log_file}" invalidate_token exit 0 fi - if [[ "${group_selection}" == *"Please create a Smart Computer Group"* ]] + + if [[ "${group_selection}" == "Please create a Smart Computer Group" ]] then # Prompt for number of days since last Inventory Update echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: New group workflow selected. Prompting for number of days since last Inventory Update" >> "${log_file}" @@ -252,22 +260,22 @@ group_name_prompt() { # Prompt user to select a Smart Computer Group from the list echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Prompting to choose a Smart Computer Group" >> "${log_file}" - group_name=$("${dialog_path}" \ - --title "Framework Fixer" \ - --message "Choose a Smart Computer Group from the list:" \ - --icon "${icon}" \ - --alignment "left" \ - --small \ - --button2 \ - --button2text "Back" \ - --messagefont "${message_font}" \ - --titlefont "${title_font}" \ - --selecttitle "Smart Computer Group" \ - --selectvalues "${group_list}" \ - --button1text "Select" \ - --json) - - if [[ $? == 0 ]] + if group_name=$( + "${dialog_path}" \ + --title "Framework Fixer" \ + --message "Choose a Smart Computer Group from the list:" \ + --icon "${icon}" \ + --alignment "left" \ + --small \ + --button2 \ + --button2text "Back" \ + --messagefont "${message_font}" \ + --titlefont "${title_font}" \ + --selecttitle "Smart Computer Group" \ + --selectvalues "${group_list}" \ + --button1text "Select" \ + --json + ) then group_name=$(echo "${group_name}" | "${plutil_path}" -extract SelectedOption raw -o - - 2>/dev/null) # Replace spaces with %20 for API call @@ -281,36 +289,37 @@ group_name_prompt() { # Prompt explaining a group with the provided name already exists group_exists() { "${dialog_path}" \ - --title "Framework Fixer" \ - --message "Oops! It looks like there is already a Smart Computer Group called ${group_name}" \ - --icon "${icon}" \ - --overlayicon "caution" \ - --alignment "left" \ - --small \ - --messagefont "${message_font}" \ - --titlefont "${title_font}" \ - --button1text "OK" + --title "Framework Fixer" \ + --message "Oops! It looks like there is already a Smart Computer Group called ${group_name}" \ + --icon "${icon}" \ + --overlayicon "caution" \ + --alignment "left" \ + --small \ + --messagefont "${message_font}" \ + --titlefont "${title_font}" \ + --button1text "OK" new_group_prompt } # Prompt for number of days since last Inventory Update days_prompt() { - days=$("${dialog_path}" \ - --title "Framework Fixer" \ - --message "OK, we will create a Smart Computer Group based on the number of days since the last Inventory Update. Please enter the number of days." \ - --textfield "Number of days","regex=^[0-9]+$,regexerror=Input must be a number,required : true" \ - --icon "${icon}" \ - --alignment "left" \ - --small \ - --button2 \ - --button2text "Back" \ - --messagefont "${message_font}" \ - --titlefont "${title_font}" \ - --json) - if [[ $? == 0 ]] + if days=$( + "${dialog_path}" \ + --title "Framework Fixer" \ + --message "OK, we will create a Smart Computer Group based on the number of days since the last Inventory Update. Please enter the number of days." \ + --textfield "Number of days, regex=^[0-9]+$, regexerror=Input must be a number, required: true" \ + --icon "${icon}" \ + --alignment "left" \ + --small \ + --button2 \ + --button2text "Back" \ + --messagefont "${message_font}" \ + --titlefont "${title_font}" \ + --json + ) then - days=$(echo ${days} | awk -F '"' '{print $4}') + days=$(echo "$days" | grep "\"Number of days\" : " | awk -F '"' '{print $4}') new_group_prompt else echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: User clicked on 'Back'" >> "${log_file}" @@ -321,18 +330,19 @@ days_prompt() { # Request the name of the Smart Computer Group to be created new_group_prompt() { echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Requesting the name for the new Smart Computer Group" >> "${log_file}" - group_name=$("${dialog_path}" \ - --title "Framework Fixer" \ - --message "Please enter a name for the new Smart Computer Group." \ - --textfield "Group Name","required" : true \ - --icon "${icon}" \ - --alignment "left" \ - --small \ - --button2 \ - --messagefont "${message_font}" \ - --titlefont "${title_font}" \ - --json) - if [[ $? == 0 ]] + if group_name=$( + "${dialog_path}" \ + --title "Framework Fixer" \ + --message "Please enter a name for the new Smart Computer Group." \ + --textfield "Group Name, required" \ + --icon "${icon}" \ + --alignment "left" \ + --small \ + --button2 \ + --messagefont "${message_font}" \ + --titlefont "${title_font}" \ + --json + ) then group_name=$(echo "${group_name}" | "${plutil_path}" -extract "Group Name" xml1 -o - - | xmllint --xpath "string(//string)" -) # Replace spaces with %20 for API call @@ -371,14 +381,14 @@ new_group_prompt() { # Prompt to indicate there are no members in the Smart Computer Group no_members_prompt() { "${dialog_path}" \ - --title "Framework Fixer" \ - --message "There are 0 members in this Smart Computer Group. No action required." \ - --icon "${icon}" \ - --alignment "left" \ - --small \ - --messagefont "${message_font}" \ - --titlefont "${title_font}" \ - --button1text "OK" + --title "Framework Fixer" \ + --message "There are 0 members in this Smart Computer Group. No action required." \ + --icon "${icon}" \ + --alignment "left" \ + --small \ + --messagefont "${message_font}" \ + --titlefont "${title_font}" \ + --button1text "OK" if [[ $? != 0 ]] then echo "$(date '+%Y-%m-%d %H:%M:%S') WARNING: User Cancelled" >> "${log_file}" @@ -390,17 +400,19 @@ no_members_prompt() { # Show number of devices in the Smart Computer Group and ask if we should remediate remediation_prompt() { - remediation_check=$("${dialog_path}" \ - --title "Framework Fixer" \ - --message "There are ${member_count} members in the Smart Computer Group. Would you like to redeploy the Jamf Management Framework on all computers in this group?" \ - --icon "${icon}" \ - --alignment "left" \ - --small \ - --button1text "No" \ - --button2text "Yes" \ - --messagefont "${message_font}" \ - --titlefont "${title_font}" \ - --json) + remediation_check=$( + "${dialog_path}" \ + --title "Framework Fixer" \ + --message "There are ${member_count} members in the Smart Computer Group. Would you like to redeploy the Jamf Management Framework on all computers in this group?" \ + --icon "${icon}" \ + --alignment "left" \ + --small \ + --button1text "No" \ + --button2text "Yes" \ + --messagefont "${message_font}" \ + --titlefont "${title_font}" \ + --json + ) if [[ $? == 2 ]] then echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Remediation choice: yes" >> "${log_file}" @@ -416,19 +428,19 @@ redeployment_prompt() { # Create a command file (needed to close the dialog later if needed) command_file="/Users/Shared/dialogIndeterminate.txt" : > "$command_file" - - "${dialog_path}" \ - --title "JSS Framework Fixer" \ - --message "We're working on it! This can take a while depending on how many computers are in the Smart Computer Group" \ - --icon "${icon}" \ - --alignment "left" \ - --small \ - --messagefont "${message_font}" \ - --titlefont "${title_font}" \ - --button1text "Cancel" \ - --progress --indeterminate \ - --commandfile "${command_file}" & - if [[ $? != 0 ]] + + if ! "${dialog_path}" \ + --title "JSS Framework Fixer" \ + --message "We're working on it! This can take a while depending on how many computers are in the Smart Computer Group" \ + --icon "${icon}" \ + --alignment "left" \ + --small \ + --messagefont "${message_font}" \ + --titlefont "${title_font}" \ + --button1text "Cancel" \ + --progress \ + --indeterminate \ + --commandfile "${command_file}" & then echo "$(date '+%Y-%m-%d %H:%M:%S') WARNING: User Cancelled" >> "${log_file}" invalidate_token @@ -455,9 +467,9 @@ create_group() { "siteId": "-1" } EOM + # Create the Smart Computer Group echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Creating group called ${group_name}" >> "${log_file}" - group_creation=$(check_response -X 'POST' "${jamf_pro_url}/api/v2/computer-groups/smart-groups" -H "accept: application/json" -H "Authorization: Bearer ${bearer_token}" -H "Content-Type: application/json" -d "${json_payload}" -b "${ap_balance_id}") if [[ $group_creation =~ ^(200|201|202|204)$ ]] then @@ -471,17 +483,16 @@ EOM } error_prompt() { - "${dialog_path}" \ - --title "Framework Fixer" \ - --message 'Oops! An error occurred. Please check "${log_file}" for more details' \ - --icon "${icon}" \ - --overlayicon "caution" \ - --alignment "left" \ - --small \ - --messagefont "${message_font}" \ - --titlefont "${title_font}" \ - --button1text "OK" - if [[ $? == 0 ]] + if "${dialog_path}" \ + --title "Framework Fixer" \ + --message "Oops! An error occurred. Please check ${log_file} for more details" \ + --icon "${icon}" \ + --overlayicon "caution" \ + --alignment "left" \ + --small \ + --messagefont "${message_font}" \ + --titlefont "${title_font}" \ + --button1text "OK" then invalidate_token exit 1 @@ -491,14 +502,14 @@ error_prompt() { # End prompt done_prompt() { "${dialog_path}" \ - --title "Framework Fixer" \ - --message "We're done!\n\nThe command to redeploy the Jamf Management Framework has been sent to all members of the Smart Computer Group." \ - --icon "${icon}" \ - --alignment "left" \ - --small \ - --messagefont "${message_font}" \ - --titlefont "${title_font}" \ - --button1text "OK" + --title "Framework Fixer" \ + --message "We're done!\n\nThe command to redeploy the Jamf Management Framework has been sent to all members of the Smart Computer Group." \ + --icon "${icon}" \ + --alignment "left" \ + --small \ + --messagefont "${message_font}" \ + --titlefont "${title_font}" \ + --button1text "OK" } ####################################################################################################### @@ -511,9 +522,18 @@ token_expiration_epoch="0" get_bearer_token() { if [[ "${auth_method}" == "user_creds" ]] then - response=$("${curl_path}" -s -u "${username}":"${api_password}" "${jamf_pro_url}"/api/v1/auth/token -X POST) - bearer_token=$(echo "${response}" | "${plutil_path}" -extract token raw -) - token_expiration=$(echo "${response}" | "${plutil_path}" -extract expires raw - | awk -F . '{print $1}') + response=$("${curl_path}" -s -u "${username}:${api_password}" "${jamf_pro_url}"/api/v1/auth/token -X POST) + bearer_token=$(echo "${response}" | "${plutil_path}" -extract token raw - 2>/dev/null) + # check token value was retrieved + if [[ -z "${bearer_token}" ]] + then + echo "$(date '+%Y-%m-%d %H:%M:%S') ERROR: Unable to retrieve bearer token" >> "${log_file}" + invalid_credentials_prompt + credential_prompt + get_bearer_token + return + fi + token_expiration=$(echo "${response}" | "${plutil_path}" -extract expires raw - 2>/dev/null | awk -F . '{print $1}') token_expiration_epoch=$(date -j -f "%Y-%m-%dT%T" "${token_expiration}" +"%s") check_token_expiration_prompt fi @@ -537,7 +557,8 @@ get_bearer_token() { check_token_expiration_prompt() { now_epoch_utc=$(date -j -f "%Y-%m-%dT%T" "$(date -u +"%Y-%m-%dT%T")" +"%s") - if [[ token_expiration_epoch -gt now_epoch_utc ]] + + if [[ -n "$token_expiration_epoch" && ($token_expiration_epoch -gt $now_epoch_utc) ]] then echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Token valid until the following epoch time: " "${token_expiration_epoch}" >> "${log_file}" else @@ -545,12 +566,12 @@ check_token_expiration_prompt() { invalid_credentials_prompt credential_prompt get_bearer_token - fi + fi } check_token_expiration() { now_epoch_utc=$(date -j -f "%Y-%m-%dT%T" "$(date -u +"%Y-%m-%dT%T")" +"%s") - if [[ token_expiration_epoch -gt now_epoch_utc ]] + if [[ $token_expiration_epoch -gt $now_epoch_utc ]] then echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Token valid until the following epoch time: " "${token_expiration_epoch}" >> "${log_file}" else @@ -560,13 +581,13 @@ check_token_expiration() { } invalidate_token() { - response_code=$("${curl_path}" -w "%{http_code}" -H "Authorization: Bearer ${bearer_token}" ${jamf_pro_url}/api/v1/auth/invalidate-token -X POST -s -o /dev/null) - if [[ "${response_code}" == 204 ]] + response_code=$("${curl_path}" -w "%{http_code}" -H "Authorization: Bearer ${bearer_token}" "${jamf_pro_url}/api/v1/auth/invalidate-token" -X POST -s -o /dev/null) + if [[ ${response_code} == 204 ]] then echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Token successfully invalidated" >> "${log_file}" bearer_token="" token_expiration_epoch="0" - elif [[ "${response_code}" == 401 ]] + elif [[ ${response_code} == 401 ]] then echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Token already invalid" >> "${log_file}" else @@ -593,10 +614,8 @@ member_list=$("${curl_path}" -X 'GET' -H "Authorization: Bearer ${bearer_token}" # Count the members member_count="0" -for item in ${member_list} -do - member_count=$(( member_count +1 )) -done +# Count the members using word count +member_count=$(echo "${member_list}" | wc -w | tr -d ' ') # Prompt explaining no computers were found if [[ -z ${member_list} ]] @@ -610,31 +629,30 @@ echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: There are ${member_count} members in th echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Checking if remediation is desired" >> "${log_file}" remediation_prompt - if [[ $remediation_check == "Yes" ]] - then - # Show Progress bar while the Jamf Management Framework is being redeployed on the computers - redeployment_prompt - - # Loop through the members of the Smart Computer Group and redeploy the Jamf Management Framework - for computer in ${member_list} - do - echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Redeploying Jamf Management Framework on Computer with ID: ${computer}" >> "${log_file}" - check_response -X 'POST' -H "Authorization: Bearer ${bearer_token}" "${jamf_pro_url}/api/v1/jamf-management-framework/redeploy/${computer}" -H 'accept: application/json' -d '' -b "${ap_balance_id}" - # Update the dialog - echo "progresstext: Redeploying Jamf Management Framework on Computer with ID: ${computer}" >> "${command_file}" - check_token_expiration - sleep 1 - done - - # Close the progress dialog. Since indeterminate progress dialogs don't close automatically we are killing the dialog process - pkill Dialog - - # Clean up - echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Cleaning up ..." >> "${log_file}" - rm /Users/Shared/dialogIndeterminate.txt - fi - invalidate_token - echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Done!" >> "${log_file}" - done_prompt +if [[ $remediation_check == "Yes" ]] +then + # Show Progress bar while the Jamf Management Framework is being redeployed on the computers + redeployment_prompt + + # Loop through the members of the Smart Computer Group and redeploy the Jamf Management Framework + for computer in ${member_list} + do + echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Redeploying Jamf Management Framework on Computer with ID: ${computer}" >> "${log_file}" + check_response -X 'POST' -H "Authorization: Bearer ${bearer_token}" "${jamf_pro_url}/api/v1/jamf-management-framework/redeploy/${computer}" -H 'accept: application/json' -d '' -b "${ap_balance_id}" + # Update the dialog + echo "progresstext: Redeploying Jamf Management Framework on Computer with ID: ${computer}" >> "${command_file}" + check_token_expiration + sleep 1 + done + + # Close the progress dialog. Since indeterminate progress dialogs don't close automatically we are killing the dialog process + pkill Dialog + + # Clean up + echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Cleaning up ..." >> "${log_file}" + rm /Users/Shared/dialogIndeterminate.txt +fi + invalidate_token + echo "$(date '+%Y-%m-%d %H:%M:%S') INFO: Done!" >> "${log_file}" + done_prompt fi -exit 0