Background
While testing a Self Service policy to install Adobe Creative Cloud Master Collection 2015, I was greeted by a Finder dialog box informing me I was nearly out of disk space.
The following script leverages JSS Parameter 4 and verifies there is enough available disk space before continuing with the policy. If there is not enough free disk space, a message is displayed to the end-user and Self Service is forcibly quit. (Is there a way to just simply stop the policy and leave Self Service running?)
Script
#!/bin/sh #################################################################################################### # # ABOUT # # Check Free Space: Leverages JSS Parameter 4 to verify there is enough available disk space before continuing with the policy. If there is not enough free disk space, a message is displayed to the end-user and Self Service is forcibly quit. # #################################################################################################### # # HISTORY # # Version 1.0, 17-Jun-2015, Dan K. Snelson # #################################################################################################### # Import logging functions source /path/to/logging/script/goes/here/logging.sh #################################################################################################### # Variables requiredSpace="$4" # Available Space Required (in GBs) availableSpace=`/usr/sbin/diskutil info / | grep "Volume Free Space:" | awk '{print $4}'` availableSpaceInt=$(/bin/echo "($availableSpace+0.5)/1" | bc) totalSpace=`/usr/sbin/diskutil info / | grep "Total Size:" | awk '{print $3}'` /bin/echo "`now` *** Check Free Space ***" >> $logFile /bin/echo "`now` Required Space: $requiredSpace" >> $logFile /bin/echo "`now` Available Space: $availableSpaceInt" >> $logFile if [ "$availableSpaceInt" -lt "$requiredSpace" ]; then /usr/sbin/jamf displayMessage -message "Insufficient Free Space Available This installation requires $requiredSpace GB. There is $availableSpace GB available. " /usr/bin/killall "Self Service" exit 1 ## Failure else /bin/echo "`now` There is enough free space available" >> $logFile fi exit 0 ## Success