
In my current organization, we are using Setup Your Mac (thanks Dan Snelson!!) to provide a zero-touch guided Mac deployment experience our end-users which has been an incredible success.
After seeing the success that we’ve had for our end-users, we started to focus on how we could cut down the time to deploy a Zoom Room purposed Mac computer. Before implementing SYM for Zoom Rooms, most/all steps taken to set up a Zoom Room Mac was manually done, including creating a dedicated Zoom Room account locally on the Mac and setting it up for Auto Login. We started with a basic deployment that would take care of our manual steps in the process by using SYM, but in the pursuit to make the process even better we decided to focus on using SYM to help with our naming convention which is in the format of ${Country}-${Building}-${RoomName}. This was not being applied at a consistent rate so we worked on SYM to help us out with the process.
One area of focus was the ability of SYM to dynamically build the buildings list based on the country of the user. During Setup Assistant, the end-user enrolling the device can select their country, so we know that this data already exists on the computer, there would be no need to ask the user their country in the Welcome Screen of SYM. Knowing this, we were able to modify our script a bit to grab the locale of the computer to determine the country and populate a list of buildings specific to that country. We’ll dive into how that is done now.
In order to get our country, we added the following snippet into our script ~line 356 (under the info-box related variables)
locale=$(defaults read /Users/$loggedInUser/Library/Preferences/.GlobalPreferences.plist AppleLocale)
This will store the language and country code into our locale
variable. For example, a user who chose English and United States would have a variable of en_US
.
Next, for this purpose, we only care about the country code associated. We can trim that up.
countryCode=${locale: -2}
Now that we have our country code, we can use case statements in bash to create our list of buildings. (Actual building names have been removed from the example)
case $countryCode in AU) country="Australia" buildings=$(cat <<EOF "Please select your building", "Building 1", "Building 2", "Building 3", "Building 4" EOF ) ;; CA) country="Canada" buildings=$(cat <<EOF "Please select your building", "Building 1", "Building 2", "Building 3", "Building 4" EOF ) ;; CN) country="China" buildings=$(cat <<EOF "Please select your building", "Building 1", "Building 2", "Building 3", "Building 4" EOF ) ;; DE) country="Germany" buildings=$(cat <<EOF "Please select your building", "Building 1", "Building 2", "Building 3", "Building 4" EOF ) ;; HK) country="Hong Kong" buildings=$(cat <<EOF "Please select your building", "Building 1", "Building 2", "Building 3", "Building 4" EOF ) ;; IN) country="India" buildings=$(cat <<EOF "Please select your building", "Building 1", "Building 2", "Building 3", "Building 4" EOF ) ;; JP) country="Japan" buildings=$(cat <<EOF "Please select your building", "Building 1", "Building 2", "Building 3", "Building 4" EOF ) ;; ko | KR) country="Korea" buildings=$(cat <<EOF "Please select your building", "Building 1", "Building 2", "Building 3", "Building 4" EOF ) ;; NL) country="Netherlands" buildings=$(cat <<EOF "Please select your building", "Building 1", "Building 2", "Building 3", "Building 4" EOF ) ;; SG) country="Singapore" buildings=$(cat <<EOF "Please select your building", "Building 1", "Building 2", "Building 3", "Building 4" EOF ) ;; TW) country="Taiwan" buildings=$(cat <<EOF "Please select your building", "Building 1", "Building 2", "Building 3", "Building 4" EOF ) ;; GB) country="United Kingdom" buildings=$(cat <<EOF "Please select your building", "Building 1", "Building 2", "Building 3", "Building 4" EOF ) ;; US) country="United States" buildings=$(cat <<EOF "Please select your building", "Building 1", "Building 2", "Building 3", "Building 4" EOF ) ;; VN) country="Vietnam" buildings=$(cat <<EOF "Please select your building", "Building 1", "Building 2", "Building 3", "Building 4" EOF ) ;; *) country="Other" ;; esac updateScriptLog "Setup Your Mac: Setting Country to: ${country}"
The above case statements will help build the list of buildings we will supply to the end-user during the Welcome Screen of SYM.
From there, we just need to make sure that the values get passed into our welcomeJSON, see below:
welcomeJSON=' { "bannerimage" : "'"${welcomeBannerImage}"'", "bannertext" : "'"${welcomeBannerText}"'", "title" : "'"${welcomeTitle}"'", "message" : "'"${welcomeMessage}"'", "icon" : "'"${welcomeIcon}"'", "iconsize" : "198.0", "button1text" : "Continue", "button2text" : "Quit", "infotext" : "'"${scriptVersion}"'", "blurscreen" : "true", "ontop" : "true", "titlefont" : "shadow=true, size=28", "messagefont" : "size=14", "selectitems" : [ { "title" : "Building", "default" : "Please select your building", "values" : [ '${buildings}' ] } ], "textfield" : [ { "title" : "Room Name", "required" : true, "prompt" : "Room Name" }, { "title" : "Asset Tag", "required" : false, "prompt" : "Please enter the seven-digit Asset Tag", "regex" : "^(AP|IP|CD)?[0-9]{7,}$", "regexerror" : "Please enter (at least) seven digits for the Asset Tag, optionally preceed by either AP, IP or CD." } ], "height" : "725" } '
We now have a dynamically built list of buildings based on the user’s country that they can select from. In my use-case, we use this information provided to make sure that our Zoom Room Macs follow our standard naming convention of ${Country}-${Building}-${roomName}.
Note: I’ve also removed all spaces in my computer names, because I don’t like them. If you need to do this as well, you can do something similar to
computerName="$country-$building-$roomName" computerName=$(echo ${computerName} | sed 's/ //g')
Thanks for checking it out!