Box Edit and Box Sync via Self Service

We’re doing a lot of work with our account over at JAMF Software, and going forward I’m going to be educating my users about using Box Sync and Box Edit to get the most out of our new setup.  However, I don’t want to hand them a sheet of instructions detailing logging into to get the installers for these services.  Surely, there is a better way.

A lot of companies are now using apps for software installers on Macs, and to be truthful that irks me a little.  I can’t plop an app into my Casper Share and easily make a policy out of it, and my personal approach to software deployment is that I don’t want (and don’t like) to do snapshot package creation.  I prefer going 100% native with the vendor’s provided installers.

So,  I whipped up a Self Service policy script (I do love Self Service):

# Pass the following from the JSS Parameter 4 to select the script's action:
# edit: Install / Uninstall Box Edit
# sync: Install / Uninstall Box Sync
# If either service is already installed the app will open with an "Uninstall" option

# Error Codes:
# 0: Script executed successfully
# 101: The downloaded file did not pass the checksum test
# 102: The downloaded Box Edit DMG failed to mount
# 103: The downloaded Box Sync app file could not be unzipped


if [[ ${installerOption} = edit ]]; then
     echo ""
     echo "Downloading Box Edit"
     webCheckSum=$(curl -sI | tr -d '\r' | awk '/Content-Length/ {print $2}')
     curl -fkS --progress-bar -o /tmp/BoxEditInstaller.dmg
     fileCheckSum=$(cksum /tmp/BoxEditInstaller.dmg | awk '{print $2}')
     if [ $webCheckSum -ne $fileCheckSum ]; then
          rm /tmp/BoxEditInstaller.dmg
          echo "The file did not download properly, Exiting..."
          exit 101
     echo "Mounting Box Edit DMG..."
     hdiutil attach -quiet /tmp/BoxEditInstaller.dmg
     if [ $? -ne 0 ]; then
          rm /tmp/BoxEditInstaller.dmg
          echo "The Box Edit DMG failed to mount properly, exiting..."
          exit 102
     cp -fR /Volumes/Box\ Edit\ Installer/Install\ Box\ /tmp/
     hdiutil eject -quiet /Volumes/Box\ Edit\ Installer/
     rm /tmp/BoxEditInstaller.dmg
     echo "Opening the Box Edit Installer app"
     open -a /tmp/Install\ Box\
     osascript -e "delay .5" -e 'tell application "Box Edit Installer" to activate'

elif [[ ${installerOption} = sync ]]; then
     echo ""
     echo "Downloading Box Sync"
     webCheckSum=$(curl -sI | tr -d '\r' | awk '/Content-Length/ {print $2}')
     curl -fkS --progress-bar -o /tmp/
     fileCheckSum=$(cksum /tmp/ | awk '{print $2}')
     if [ $webCheckSum -ne $fileCheckSum ]; then
          rm /tmp/
          echo "The file did not download properly, Exiting..."
          exit 101
     echo "Unzipping the Box Sync app..."
     unzip -oq /tmp/ -d /tmp/
     if [ $? -ne 0 ]; then
          echo "The Box Sync app failed to unzip properly, exiting..."
          exit 103
     rm -f /tmp/
     echo "Opening the Box Sync Installer app"
     open -a /tmp/Box\ Sync\
     osascript -e "delay .5" -e 'tell application "Box Sync Installer" to activate'

echo "Finished"
exit 0

There’s very little here that’s special.  The script does perform some error checking to make sure the download and/or extraction process completes appropriately and throws messages into the logs so you have a better idea of what happened if it failed.  Because the Box installer apps present an “Uninstall” option if you run them and the service is already present these policies do double-duty for removal.

For me, using this script means that I don’t have to worry about repackaging the installer apps and putting them into the Casper Shares to achieve the same end result (the user having to click through the process).  It also means that every user will always receive the most recent version of both of these apps when they go to install them.  By using the toggle parameter I only need the one script to handle both options.  Here’s what the complete policies look like in my Self Service:

Box Edit Self Service

Box Sync Self Service

The downside to this script is that I will need to update/rewrite it if changes how they package or deploy the installers.  For now, its elegance is in its simplicity to the user.  Feel free to take this and apply it to your own organization if you’re looking to distribute these tools!

P.S. In case you were curious, the “JAMF Software User Guide” is being created in iBooks Author.


7 thoughts on “Box Edit and Box Sync via Self Service

  1. Box sync has been updated to be an app now and not a preference pane. your script pulls the older preference pane. I am not skilled enough to capture the url redirect that happens for the Box Sync 4 installer and update your script. Any assistance?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s