Box Edit and Box Sync via Self Service

We’re doing a lot of work with our Box.com 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 Box.com 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):

#!/bin/bash
# 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

installerOption="$4"

if [[ ${installerOption} = edit ]]; then
     echo ""
     echo "Downloading Box Edit"
     webCheckSum=$(curl -sI https://sync.box.com/static/BoxEdit/BoxEditInstaller.dmg | tr -d '\r' | awk '/Content-Length/ {print $2}')
     curl -fkS --progress-bar https://sync.box.com/static/BoxEdit/BoxEditInstaller.dmg -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
     fi
     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
     fi
     cp -fR /Volumes/Box\ Edit\ Installer/Install\ Box\ Edit.app /tmp/
     hdiutil eject -quiet /Volumes/Box\ Edit\ Installer/
     rm /tmp/BoxEditInstaller.dmg
     echo "Opening the Box Edit Installer app"
     open -a /tmp/Install\ Box\ Edit.app
     osascript -e "delay .5" -e 'tell application "Box Edit Installer" to activate'

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

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 Box.com 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 Box.com tools!

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

Advertisements

6 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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s