Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # NikeThinProvisioningHelper.sh - copyright© 2016, david koff
- # No portion of this script can be used without also pasting this entire header.
- #
- # SYNOPSIS
- # script executes the retail thin-imaging process
- #
- # DESCRIPTION
- # This script profides a series of checks and actions for new client enrollment.
- #
- # CREDITS & THANKS
- # Borrows some kick-ass concepts, ideas and code from the über talented Jeff Grisso, Daniel Chapa & Mark Stratman.
- # https://github.com/mstratman/cocoadialog
- #
- # CHANGE LOG
- # Date Version Description
- #--------------------------------------------------------------------------------------------------
- # 01/20/2016 1.0 - Created First Retail build with retail JSS API.
- # 02/15/2016 - Fixed JAMF curl download errors, initial recon and some flow logic.
- # 02/18/2016 1.1 - Fixed secureExit and JAMF binary install bugs.
- # 02/24/2016 1.1.2 - Added flushPolicyHistory & Bomgar install, fixed syntax/order with stopJamfHelper.
- # 02/18/2016 1.1.3 - Removed verbose policy logs once Casper is installed.
- # 04/06/2016 1.1.4 - Added asking for the type of experience and floor number for location.
- # 04/07/2016 1.1.5 - Added escape routine with visual feedback to secure exit sub-routine.
- # 04/10/2016 2.0 - New, unified custom trigger for imaging process.
- # 04/21/2016 2.1 - Fixed final touch file; removed old experience codes; added pre-flight user check.
- # 04/25/2016 2.2 - Added new computer name confirm message, fixed progress bar status.
- # 04/29/2016 2.3 - Added naming convention fork for breakroom iMacs.
- # 04/29/2016 2.4 - Changed fullscreen jamfHelper notifications to update during the imaging process.
- # 05/03/2016 2.5 - Changed log to use simple name and to pause for full Bomgar install.
- # 05/04/2016 2.6 - Created GUI alerts for each error to educate end-user.
- # 06/04/2016 2.7 - Removed certain choices from dropdown menus. Added country codes.
- # 07/28/2016 3.0 - Major rev which includes:
- # * Added country codes for emerging markets
- # * Changed CocoaDialogue pop-up error window functionality
- # * Fixed code to isolate CocoaDialogue button presses
- # * Included initial error code/description
- # * Deleted migrationStatus function as we'll want to thin-image regardless
- # * Changed progress bar to only start once Bomgar/JAMF install begins
- # * Dropped NikeTools icon into Resources folder for use in CocoaDialogue
- # * Changed code to isolate if an ethernet cable is plugged in to any port
- # 07/28/2016 3.1 - Changes include:
- # * altered ethernet test response to "baseT" as 10.11.6 changed response verbiage
- # * REVERTED store number request to accept either 5 or 6 digit entry
- # * set autoproxy discovery to DISABLE
- # 09/16/2016 3.2 - syntax checked with "shellcheck" and corrected where indicated to avoid deprecated syntax.
- # 10/18/2016 3.3 - Changes include:
- # * updated for use MacOS Sierra
- # * updated list of included countries in dropdown menu and fixed mis-spellings
- # * fixed syntax error for power source check
- # * improved verbiage when prompting for computer/experience number
- # * changed to a green checkmark icon for the final dialogue, when imaging is successful
- # * force users to select a country & experience from dropdown menu
- # 10/26/2016 3.4 - Changes include:
- # * reverting to standard naming convention
- # * convention is: RTGEOStoreNumberExperienceNameExperienceNumber or "RTUS000368ID001"
- ####################################################################################################
- set -u ### Set Verbose error check during execution
- ####################################################################################################
- ### Set Variables
- ####################################################################################################
- oldifs="$IFS" #Internal Field Separator
- counter=0
- password="nike"
- jamf="/usr/local/bin/jamf"
- osVer="$(sw_vers -productVersion)"
- Bomgar="$(sudo launchctl list | grep bomgar <<< "${password}")"
- NikeUserPresent="$(dscl . -list /Users | grep nike)"
- NikeUserAdmin="$(dscl . -read /Groups/admin | grep nike)"
- userCheck="$(ls /Users | wc -l | awk '{ print $1 }')"
- # Application recource folder
- AppDir="$(dirname "$0")"
- CD="${AppDir}/../Resources/cocoaDialog.app/Contents/MacOS/cocoaDialog"
- icon="${AppDir}/../Resources/success.png"
- # Quick Add locations
- quickAddDir="/tmp"
- quickAdd="${quickAddDir}/QuickAdd"
- # Initial Error Codes
- ErrorCode="THIN IMAGING ABORTED"
- ErrorExplain="The thin-imaging process has been halted on this Mac."
- ####################################################################################################
- ### Initial Cleanup
- ####################################################################################################
- sudo -S rm -fv /var/NikeRetail.* <<< "${password}"
- sudo -S rm -fv /var/touch.txt <<< "${password}"
- sudo -S rm -drv /Library/Logs/Nike/ <<< "${password}"
- sudo -S rm -Rvf "${quickAdd}".* <<< "${password}"
- sudo -S rm -Rf /tmp/cookie.txt
- ####################################################################################################
- ### Script logging
- ####################################################################################################
- appName="NikeRetail-ThinImaging.InstallBase"
- appVer="3.4"
- appAuthor="David Koff"
- appDepartment="Nike Retail Mobility"
- appDate="01/20/2016"
- appUpDate="10/26/2016"
- sudo -S mkdir /Library/Logs/Nike <<< "${password}"
- logFile="/Library/Logs/Nike/${appName}.log"
- sudo -S touch $logFile <<< "${password}"
- sudo -S chmod 777 $logFile <<< "${password}"
- exec >> $logFile 2>&1
- ####################################################################################################
- #Functions
- ####################################################################################################
- appLog() {
- time="$(date +%H:%M:%S)"
- printf "${time}: ${1}"
- }
- assetTagPrompt() {
- stopProgressBar
- AssetInput=$($CD inputbox \
- --string-output \
- --title "Enter the Asset Tag" \
- --informative-text "The Nike asset tag barcode sticker can be found on the back or bottom of this computer. It starts with the letter 'N'. Please enter the tag number." \
- --button1 "OK" | awk 'NR==2{print}')
- ## Convert assetTag to uppercase
- assetTag=$(tr '[:lower:]' '[:upper:]' <<< "${AssetInput}")
- appLog "The assetTag is set to ${assetTag}.\n"
- ## Confirm correct length
- if [[ ${#assetTag} -ne "10" ]]; then appLog "Incorrect asset tag entered. Prompting user for re-entry.\n"
- $CD msgbox --no-newline \
- --text "Error: Incorrect Asset Tag Entered" \
- --informative-text "You must enter a TEN-DIGIT number such as 'N000226379'. Please try again..." \
- --button1 "OK" \
- --icon "x"
- assetTagPrompt
- else
- appLog "Asset Tag seems valid, continuing.\n"
- fi
- }
- confirmContinue() {
- Continue=$($CD msgbox \
- --no-newline \
- --title "Nike Retail Thin-Imaging" \
- --text "NIKE RETAIL IMAGING ALERT:" \
- --informative-text "You are about to image a Macintosh for Nike Retail. The process takes 30-60min depending on your internet speed. If you are ready to continue, click OK. If not, click Cancel and this script will terminate." \
- --float \
- --icon-file $"{AppDir}"/../Resources/NikeTools.icns \
- --button1 "OK" \
- --button2 "Cancel" | awk 'NR==1{print}')
- ## Confirm Result
- if [ "$Continue" = "2" ]; then appLog "The Cancel button has been pressed. Exiting script. \n"
- secureExit
- exit 1
- else
- appLog "The user has chosen to proceed. Continuing script. \n"
- fi
- }
- confirmMachineName() {
- # Naming convention is now unified for all Macs with same syntax
- ComputerName=RT$GEO$StoreNumb$EXP$ExpNumb
- MachineName=$($CD msgbox \
- --no-newline \
- --title "Confirm Computer Name" \
- --text "Please note this Mac's new name:" \
- --informative-text "$ComputerName \
- To begin thin-imaging, Click 'OK'. To cancel, click 'Cancel'." \
- --float \
- --icon-file "${AppDir}"/../Resources/NikeTools.icns \
- --button1 "OK" \
- --button2 "Cancel" | awk 'NR==1{print}')
- ## Confirm Result
- if [ "$MachineName" = "2" ]; then appLog "The Cancel button has been pressed. Exiting script. \n"
- secureExit
- exit 1
- else
- appLog "The user has chosen to proceed. Continuing script. \n"
- fi
- }
- ctrl_c() {
- printf "CTL+C was caught.\n"
- ErrorCode="CTRL+C Pressed"
- ErrorExplain="CTRL+C was pressed by tech. Script now ending."
- secureExit
- }
- logHead() {
- printf -- "-------------------------------------------\n"
- printf "Start: $(date)\n"
- printf "Program name: ${appName}\n"
- printf "ProgramVersion: ${appVer}\n"
- printf "Author: ${appAuthor}\n"
- printf "Development Department: ${appDepartment}\n"
- printf "Program Creation Date: ${appDate}\n"
- printf "Program Modification date: ${appUpDate}\n"
- printf -- "-------------------------------------------\n"
- }
- progressUpdate() {
- echo "$1" >> /tmp/hpipe
- }
- request_Country() {
- stopProgressBar
- Country=$($CD dropdown \
- --title "Select a Country" \
- --text "Select the country or region where this Mac will live." \
- --items "Click Here to Select a Country" "ARGENTINA" "AUSTRALIA" "BRAZIL" "CANADA" "CHILE" "CHINA" "EMEA" "INDIA" "JAPAN" "KOREA" "MALAYSIA" "MEXICO" "NEW ZEALAND" "SINGAPORE" "SOUTH AFRICA" "SOUTH KOREA" "THAILAND" "URUGUAY" "USA" "OTHER" \
- --button1 "Ok" --string-output --no-cancel --float | awk 'NR==2{print}')
- # force response, then based on it, create file for auto-detection
- if [ "$Country" = "ARGENTINA" ]; then GEO="AR"
- elif [ "$Country" = "AUSTRALIA" ]; then GEO="AU"
- elif [ "$Country" = "BRAZIL" ]; then GEO="BR"
- elif [ "$Country" = "CANADA" ]; then GEO="CA"
- elif [ "$Country" = "CHILE" ]; then GEO="CL"
- elif [ "$Country" = "CHINA" ]; then GEO="CN"
- elif [ "$Country" = "EMEA" ]; then GEO="EM"
- elif [ "$Country" = "INDIA" ]; then GEO="IN"
- elif [ "$Country" = "JAPAN" ]; then GEO="JP"
- elif [ "$Country" = "KOREA" ]; then GEO="KR"
- elif [ "$Country" = "MALAYSIA" ]; then GEO="MY"
- elif [ "$Country" = "MEXICO" ]; then GEO="MX"
- elif [ "$Country" = "NEW ZEALAND" ]; then GEO="NZ"
- elif [ "$Country" = "SINGAPORE" ]; then GEO="SG"
- elif [ "$Country" = "SOUTH AFRICA" ]; then GEO="ZA"
- elif [ "$Country" = "SOUTH KOREA" ]; then GEO="KR"
- elif [ "$Country" = "THAILAND" ]; then GEO="TH"
- elif [ "$Country" = "URUGUAY" ]; then GEO="UY"
- elif [ "$Country" = "USA" ]; then GEO="US"
- elif [ "$Country" = "OTHER" ]; then GEO="ZZ"
- elif [ "$Country" = "Click Here to Select a Country" ]; then request_Country
- fi
- sudo -S touch /var/NikeRetail.CountryCode."${GEO}" <<< "${password}"
- appLog "The country is: $Country. An ID file was created at: /var/NikeRetail.CountryCode.${GEO} \n"
- }
- request_Experience() {
- stopProgressBar
- Experience=$($CD dropdown \
- --title "What Kind of Mac Is This?" \
- --text "Choose the type of Mac you need." \
- --items "Click Here to Select Type of Mac" "Breakroom iMac" "NikeID" "Athlete Macbook" "Caching Server" "Misc" \
- --button1 "Ok" --string-output --no-cancel --float | awk 'NR==2{print}')
- # force response, then based on it, create file for auto-detection
- if [ "$Experience" = "Breakroom iMac" ]; then EXP="BR"
- elif [ "$Experience" = "NikeID" ]; then EXP="ID"
- elif [ "$Experience" = "Athlete Macbook" ]; then EXP="AM"
- elif [ "$Experience" = "Caching Server" ]; then EXP="CS"
- elif [ "$Experience" = "Click Here to Select Type of Mac" ]; then request_Experience
- fi
- sudo -S touch /var/NikeRetail.ExperienceCode."${EXP}" <<< "${password}"
- appLog "This Mac will be set as: $Experience. An ID file was created at: /var/NikeRetail.ExperienceCode.${EXP} \n"
- }
- request_ExperienceNumber() {
- ExpNumb=$($CD inputbox \
- --string-output \
- --title "Enter the Experience Number" \
- --informative-text "For the first Mac in a series, enter '001'. For the second, enter '002', etc.
- Please enter a three-digit number now." \
- --button1 "OK" | awk 'NR==2{print}')
- ## Confirm correct length
- if [[ ${#ExpNumb} -ne "3" ]]; then appLog "Incorrect Mac number entered. Prompting user for re-entry.\n"
- $CD msgbox --no-newline \
- --text "Error: Incorrect Number Entered" \
- --informative-text "You must enter a THREE-DIGIT number such as '001'. Please try again..." \
- --button1 "OK" \
- --icon "x"
- request_ExperienceNumber
- else
- appLog "The experience number is: $ExpNumb. \n"
- fi
- }
- request_StoreNumber() {
- stopProgressBar
- # The inputbox call differs from the standard-input call by also providing a cancel button.
- StoreNumb=$($CD inputbox \
- --string-output \
- --title "Enter the Store Number" \
- --informative-text "Please enter a 5 or 6-DIGIT store number. For example: 00368" \
- --button1 "Next" | awk 'NR==2')
- ## Confirm if store number is correct length
- if [ ${#StoreNumb} -lt "5" ] || [ ${#StoreNumb} -gt "7" ]; then appLog "Incorrect store number entered. Prompting user for re-entry.\n"
- $CD msgbox --no-newline \
- --text "Error: Incorrect Store Number Entered" \
- --informative-text "You must enter a FIVE or SIX-DIGIT number such as '00368'. Please try again..." \
- --button1 "OK" \
- --icon "x"
- request_StoreNumber
- else
- appLog "The Nike Store number is: $StoreNumb. \n"
- fi
- }
- secureExit() {
- stopProgressBar
- if [ "$ErrorCode" = "THIN IMAGING COMPLETED" ]; then ## Show good news icon
- $CD msgbox --no-newline \
- --title "Imaging Complete" \
- --text "$ErrorCode" \
- --informative-text "$ErrorExplain" \
- --float \
- --icon-file "$icon" \
- --button1 "OK"
- else ## Show bad news icon
- $CD msgbox --no-newline \
- --title "Now Quitting" \
- --text "$ErrorCode" \
- --informative-text "$ErrorExplain" \
- --float \
- --icon "x" \
- --button1 "OK"
- fi
- rm -f /tmp/hpipe
- rm /tmp/output.txt
- rm -Rf /tmp/QuickAdd.pkg
- rm -Rf /tmp/cookie.txt
- [ "$oldifs" != "" ] && IFS=$oldifs
- }
- setMachineName() {
- echo ""
- echo "### Set Mac Name..."
- sudo -S scutil --set LocalHostName "$ComputerName" <<< "${password}"
- sudo -S scutil --set HostName "$ComputerName" <<< "${password}"
- sudo -S scutil --set ComputerName "$ComputerName" <<< "${password}"
- appLog "HostName is: $(scutil --get HostName). \n"
- appLog "LocalHostName is: $(scutil --get LocalHostName). \n"
- appLog "ComputerName is: $(scutil --get ComputerName). \n"
- }
- startJamfHelper() {
- appLog "Executing jamfHelper \n"
- "${AppDir}/../Resources/jamfHelper.app/Contents/MacOS/jamfHelper" -windowType fs -heading "Nike Retail Thin Imaging:" -alignHeading center -description 'Phase 1 - Base Installations: Now beginning.
- You will be updated as the process continues.' -icon "${AppDir}/../Resources/nikeswoosh.png" &
- appLog "Done\n"
- }
- startProgressBar() {
- appLog "Starting Progress bar... "
- rm -f /tmp/hpipe; sleep 1; mkfifo /tmp/hpipe
- $CD progressbar \
- --indeterminate \
- --title "Nike Retail Thin Provisioning" \
- --text "Performing pre-imaging checks. Please stand by..." < /tmp/hpipe &
- exec 3<> /tmp/hpipe; echo -n . >&3
- appLog "Done\n"
- }
- stopProgressBar() {
- appLog "Stopping Progress bar... "
- exec 3>&-
- appLog "Done\n"
- }
- ####################################################################################################
- #Script
- ####################################################################################################
- ### trap ctrl-c and call ctrl_c()
- trap ctrl_c INT
- ### Confirm user wishes to continue
- confirmContinue
- ####### PRE-FLIGHT CHECKS BEGIN ##################
- logHead
- startProgressBar
- # check for and remove any previous JAMF clients
- if [ -f "$jamf" ]; then
- echo "Previous install of jamf has been found. Now deleting..."
- sudo -S jamf removeFramework <<< "${password}"
- fi
- echo ""
- echo "### Look for unexpected users & if found prompt"
- progressUpdate "1 Checking for existing users..."
- if [[ "$userCheck" -gt "3" ]]; then
- stopProgressBar
- ErrorCode="Too Many User Accounts Found:"
- ErrorExplain="RetailMyMac.app only works if the 'nike' user is the ONLY user account on this Mac.
- Please restore this Mac to its 'out-of-box' state. On first boot, create a user account named 'nike' with the password 'nike'. Do not create any other user account. Then re-run RetailMyMac.app."
- appLog "Error: Too Many User Accounts Found. Ending script & informing user. \n"
- appLog "ls -la /Users \n"
- secureExit
- exit 0
- else
- appLog "No Extra users were found in /Users. \n"
- fi
- echo ""
- echo "### Confirm the Nike user account is present."
- progressUpdate "1 Confirm the Nike user account is present.."
- if [ "$NikeUserPresent" = "nike" ]; then
- appLog "The Nike user account has been found. \n"
- else
- stopProgressBar
- ErrorCode="Nike User Account Not Found:"
- ErrorExplain="Please create one administrative user account named 'nike' with the password 'nike'. Then re-run RetailMyMac.app."
- appLog "Error: Nike user account was not found. Ending script & informing user. \n"
- secureExit
- exit 0
- fi
- echo ""
- echo "### Confirm the Nike user account is administrative."
- progressUpdate "1 Confirm the Nike user account is administrative..."
- if [ ! -z "$NikeUserAdmin" ]; then
- appLog "The Nike user account is confirmed as administrative. \n"
- else
- stopProgressBar
- ErrorCode="Nike User Account Not Administrative:"
- ErrorExplain="Please ensure the 'nike' user account has been made administrative. Then re-run RetailMyMac.app."
- appLog "Error: Nike user account is not administrative. Ending script & informing user. \n"
- secureExit
- exit 0
- fi
- echo ""
- echo "### Confirm local credentials are nike:nike"
- progressUpdate "1 Checking local account credentials..."
- sudo -S touch /var/touch.txt <<< "nike"
- if [[ "$?" == "0" ]]; then
- appLog "User account has been set up correctly with user name, password and admin rights. \n"
- else
- stopProgressBar
- ErrorCode="Nike user account password must be changed:"
- ErrorExplain="The password for the Nike user account must be set to 'nike'. Please change the password from within System Preferences.
- After appliying the change, restart the computer and re-launch RetailMyMac.app"
- appLog "Error: Nike user account password must be changed. Ending script & informing user. \n"
- open /System/Library/PreferencePanes/Accounts.prefPane
- secureExit
- exit 0
- fi
- echo ""
- echo "### Disable Auto Proxy on all valid ports"
- progressUpdate "1 Disabling auto proxy on all ports..."
- appLog "Disabling AutoProxy Discovery on all ports AND Checking OS Level... \n"
- appLog "Force Mac to detect new hardware. \n"
- sudo -S networksetup -detectnewhardware <<< "${password}"
- appLog "Sleep 5 to allow detection to conclude... \n"
- sleep 5
- appLog "Start detection logic. \n"
- if [[ "${osVer}" == 10.11* ]] || [[ "${osVer}" == 10.12* ]]; then
- appLog "OS is ${osVer}. \n"
- list="$(networksetup -listallnetworkservices | grep -v 'An asterisk')"
- appLog "Hardware ports detected: \n"
- appLog "$list \n"
- appLog "DISABLE auto proxy discovery on detected ports. \n"
- echo "$list" | while read lines
- do
- case "$lines" in
- "Display Firewire"*)
- ;;
- Firewire*)
- ;;
- Bluetooth*)
- ;;
- *)
- echo "$password" | sudo -S networksetup -setproxyautodiscovery "$lines" off
- appLog "AutoProxy has been DISABLED for: $lines. \n"
- ;;
- esac
- done
- else
- stopProgressBar
- ErrorCode="Mac OS is not Current:"
- ErrorExplain="The thin provisioning process is ONLY designed to work with Mac OS X 10.11 and newer. Please update your system to Mac OS X 10.11 then re-run RetailMyMac.app."
- appLog "This version of the Mac OS -- $(sw_vers -productVersion) -- must be updated. Ending script & informing user. \n"
- secureExit
- exit 0
- fi
- echo ""
- echo "### Check Ethernet Connection"
- progressUpdate "1 Checking network connection..."
- ethernetCheck="$(ifconfig -a | grep baseT)"
- if [[ -z $ethernetCheck ]]; then
- stopProgressBar
- ErrorCode="Ethernet not connected:"
- ErrorExplain="An Ethernet cable is not plugged in. Please connect an Ethernet cable and then re-run this app."
- appLog "FAILED ethernet check. Ending script & informing user. \n"
- secureExit
- exit 0
- else
- appLog "CONFIRMED this Mac is using Ethernet. \n"
- fi
- echo ""
- echo "### Check for AC Power"
- progressUpdate "1 Checking for AC power..."
- powerMode=`pmset -g ps | awk 'NR>1{exit};1' | awk '{print $4,$5}' | sed "s/'//g"`
- if [[ $powerMode == "AC Power" ]]; then
- appLog "CONFIRMED on AC Power. \n"
- else
- stopProgressBar
- ErrorCode="Not Plugged into AC Power:"
- ErrorExplain="Your system is not connected to AC power. Please attach an AC power cord and re-run RetailMyMac.app."
- appLog "FAILED AC power check. Ending script & informing user. \n"
- secureExit
- exit 0
- fi
- echo ""
- echo "### Check for Free HDD Space"
- progressUpdate "1 Checking for enough free storage space..."
- freeSpace="$(df -Hl | grep -A 1 "Mounted on" | grep -v "Avail" | awk '{print $4}' | sed '$s/.$//')"
- appLog "# of GB avail as freespace on HD is: $freeSpace. \n"
- if [[ "$freeSpace" -le "20" ]]; then
- stopProgressBar
- ErrorCode="Not Enough FreeSpace on Hard Drive:"
- ErrorExplain="Your Boot Volume has less than 20GB free. Please free up some space and re-run RetailMyMac.app."
- appLog "Boot volume has less than 20GB free. Ending script & informing user. \n"
- secureExit
- exit 0
- else
- appLog "CONFIRMED: enough space to continue... \n"
- fi
- ####### PRE-FLIGHT CHECKS DONE ##################
- progressUpdate "1 Checks done."
- echo ""
- echo "### Adding touch file to indicate thin-imaging is beginning."
- appLog "Creating touchfile for revised thin provisioning process. \n"
- appLog "$password" | sudo -S mkdir /var/nike
- appLog "$password" | sudo -S touch /var/nike/.thinImageProcess_beginning
- echo ""
- echo "### Querying for Computer Naming Info & Setting Final Name"
- request_Country
- request_Experience
- request_ExperienceNumber
- request_StoreNumber
- assetTagPrompt
- sleep 2
- confirmMachineName
- setMachineName
- echo ""
- echo "### Downloading JAMF Client"
- startProgressBar
- progressUpdate "1 Installing Casper software. Please stand by..."
- appLog "Attempting download of quickadd.pkg. \n"
- curl -k https://cmext01.nike.com/quickadd/quickadd.pkg.zip -o "${quickAdd}.zip"
- unzip -t "${quickAdd}.zip" && unzip "${quickAdd}.zip" -d "${quickAddDir}"
- if [ ! -f "${quickAdd}.pkg" ]; then
- echo "" && appLog "ERROR: CURL OF QUICKADD FAILED. TRYING SECOND LINK. \n"
- curl -k https://cmint01.nike.com/quickadd/quickadd.pkg.zip -o "${quickAdd}.zip"
- unzip -t "${quickAdd}.zip" && unzip "${quickAdd}.zip" -d "${quickAddDir}"
- if [ ! -f "${quickAdd}.pkg" ]; then
- stopProgressBar
- ErrorCode="Can't Download The Casper Software:"
- ErrorExplain="Your Mac isn't able to download the JAMF binary. Please contact your network administrator and report this error."
- appLog "ERROR: UNABLE TO DOWNLOAD JAMF QUICKADD. Contact your administrator. \n"
- secureExit
- exit 0
- fi
- fi
- echo ""
- echo "### Installing JAMF Client"
- appLog "SUCCESS: DOWNLOAD OF QUICKADD FINISHED. NOW INSTALLING JAMF. \n"
- appLog "$password" | sudo -S installer -pkg "${quickAdd}.pkg" -allowUntrusted -target /
- appLog "The quickadd package has installed. See /var/log/install.log for details. \n"
- echo ""
- echo "### Install Bomgar"
- progressUpdate "1 Downloading Bomgar Remote Software. Please stand by..."
- sudo -S $jamf policy -trigger installbomgar <<< "${password}"
- ### Wait for installation to complete
- while [ $counter -lt 10 ]; do
- if [[ -z $Bomgar ]]; then
- appLog "Installing Bomgar and waiting for Launch Agents to load... \n"
- progressUpdate "1 Bomgar installation in progress, Please stand by..."
- sleep 5
- let counter=counter+1
- else
- appLog "SUCCESS: Bomgar has been installed. \n"
- break
- fi
- done
- echo ""
- echo "### Starting JAMF Tasks"
- progressUpdate "1 starting lock screen."
- appLog "Starting Lock Screen. \n"
- stopProgressBar
- startJamfHelper
- echo ""
- appLog "Executing initial recon to set the Asset Tag. \n"
- sudo -S $jamf recon -assetTag "${assetTag}" <<< "${password}" && sleep 2
- echo ""
- appLog "Executing verbose jamf manage. \n"
- sudo -S $jamf manage <<< "${password}" && sleep 2
- echo ""
- appLog "Executing verbose jamf recon again. \n"
- sudo -S $jamf recon <<< "${password}" && sleep 2
- echo ""
- appLog "Flushing any previous jamf policies for this piece of hardware. \n"
- sudo -S $jamf flushPolicyHistory <<< "${password}"
- echo ""
- echo "### Starting Thin Provisioning process...Please see JAMF log for process"
- sudo -S $jamf policy -trigger OSX-UpgradeScripts <<< "${password}" &
- appLog "+++++++++++++++++++++++++++++++++++++++++++ \n"
- appLog "script has completed: ${appName}. \n"
- ErrorCode="THIN IMAGING COMPLETED"
- ErrorExplain="The thin-imaging process has completed on this Mac. The computer will restart itself in approximately two minutes."
- secureExit
- appLog "+++++++++++++++++++++++++++++++++++++++++++"
- #catch-all exit
- appLog "ERROR: catch-all exit was reached! \n"
- exit 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement