From 369fbff7304fc72e1e63428ba5046847deec3115 Mon Sep 17 00:00:00 2001 From: Zack T Date: Fri, 13 May 2022 19:05:52 -0700 Subject: [PATCH] v1.3.0 = Add logic to determine if the Issue code was valid + Improved the curl command for the download of the Support Application + Will now be able to determine if the Issue Code Name is valid or not --- .../Run-BomgarSupportOnDemand.sh | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/Software/Beyond Trust Bomgar/Run-BomgarSupportOnDemand.sh b/Software/Beyond Trust Bomgar/Run-BomgarSupportOnDemand.sh index b4fccce..3adee14 100644 --- a/Software/Beyond Trust Bomgar/Run-BomgarSupportOnDemand.sh +++ b/Software/Beyond Trust Bomgar/Run-BomgarSupportOnDemand.sh @@ -3,7 +3,7 @@ ################################################################################################### # Script Name: Run-BomgarSupportOnDemand.sh # By: Zack Thompson / Created: 5/11/2020 -# Version: 1.2.0 / Updated: 1/6/2022 / By: ZT +# Version: 1.3.0 / Updated: 5/12/2022 / By: ZT # # Description: Utilizing the Bomgar API, downloads a Bomgar Support Client and assigns it to the # supplied team's queue based on the passed parameters. @@ -107,8 +107,8 @@ delete_file() { lookup_model() { # Get the Friendly Model Name from Apple -/usr/bin/curl -s "https://support-sp.apple.com/sp/product?cc=${1}" | - /usr/bin/xmllint --format - | xpath_tool "/root/configCode/text()" 2>/dev/null + /usr/bin/curl -s "https://support-sp.apple.com/sp/product?cc=${1}" | + /usr/bin/xmllint --format - | xpath_tool "/root/configCode/text()" 2>/dev/null } @@ -176,26 +176,41 @@ if [[ -n $pre_existing_dmg ]]; then fi +# Delete pre-existing failure file, just in case +/bin/rm "/private/tmp/start_session" > /dev/null 2>&1 + echo "Downloading client..." -# Download the Support Application -- +# Download the Support Application # Using a User Agent here that downloads a .dmg as I # wasn't able get a .zip to extract via cli and work. -exitStatus1=$( su - "${consoleUser}" -c "cd ${temp_dir} && /usr/bin/curl \ - --silent --show-error --fail \ +exitStatus1=$( /usr/bin/su - "${consoleUser}" -c "/usr/bin/curl \ + --silent --show-error --fail --location --request POST \ --url \"https://${bomgarSiteURL}/api/start_session\" \ --header 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/601.5.17 (KHTML, like Gecko) Version/9.1 Safari/601.5.17' \ - -d issue_menu=1 \ - -d codeName=\"${issueCodeName}\" \ - -d customer.name=\"${fullName} (${consoleUser})\" \ - -d customer.details=\"${customerDetails}\" \ + --header 'Content-Type: application/x-www-form-urlencoded' \ + --data-urlencode issue_menu=1 \ + --data-urlencode codeName=\"${issueCodeName}\" \ + --data-urlencode customer.name=\"${fullName} (${consoleUser})\" \ + --data-urlencode customer.details=\"${customerDetails}\" \ --compressed \ --remote-name \ - --remote-header-name" - ) + --remote-header-name \ + --output-dir \"${temp_dir}\"" +) + exitCode1=$? exitCheck $exitCode1 "${exitStatus1}" "Failed to download the Remote Support application!" +if [[ -e "/private/tmp/start_session" && $( /bin/cat "/private/tmp/start_session" ) =~ .*ERROR:[[:space:]]Sorry,[[:space:]]this[[:space:]]issue[[:space:]]code[[:space:]]name[[:space:]]is[[:space:]]not[[:space:]]valid\..* ]]; then + + /bin/rm "/private/tmp/start_session" + echo "ERROR: The specified issue code name is not valid" + echo "***** Run BomgarSupportOnDemand Process: FAILED *****" + exit 3 + +fi + # Get the filename of the .dmg file bomgarDMG=$( find_bomgar_dmg )