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?)

1#!/bin/sh2####################################################################################################3#4# ABOUT5#6# 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.7#8####################################################################################################9#10# HISTORY11#12# Version 1.0, 17-Jun-2015, Dan K. Snelson13#14####################################################################################################15# Import logging functions16source /path/to/logging/script/goes/here/logging.sh17####################################################################################################1819# Variables20requiredSpace="$4" # Available Space Required (in GBs)21availableSpace=`/usr/sbin/diskutil info / | grep "Volume Free Space:" | awk '{print $4}'`22availableSpaceInt=$(/bin/echo "($availableSpace+0.5)/1" | bc)23totalSpace=`/usr/sbin/diskutil info / | grep "Total Size:" | awk '{print $3}'`24/bin/echo "`now` *** Check Free Space ***" >> $logFile25/bin/echo "`now` Required Space: $requiredSpace" >> $logFile26/bin/echo "`now` Available Space: $availableSpaceInt" >> $logFile2728if [ "$availableSpaceInt" -lt "$requiredSpace" ]; then29 /usr/sbin/jamf displayMessage -message "Insufficient Free Space Available3031This installation requires $requiredSpace GB.32There is $availableSpace GB available.3334"35 /usr/bin/killall "Self Service"36 exit 1 ## Failure37else38 /bin/echo "`now` There is enough free space available" >> $logFile39fi404142exit 0 ## Success

