Hello,
By using DerFlounders post on upgrading OSX, I've started preparing a package for updating to macOS Sierra for those in our organization who are still on older versions of OSX. I got the following script from the same source but have modified it a bit...sadly, I know very little of scripting and while this seems to work, the issue is that while the script will prompt me if my power isn't connected (for example), it will not stop the script or policy from running. Everything else seems fine so far though.
Would anyone be able to assist me with what I'm doing wrong?
#!/bin/bash
available_free_space=$(df -g / | tail -1 | awk '{print $4}')
osvers=$(sw_vers -productVersion | awk -F. '{print $2}')
PowerSource=$(pmset -g ps | grep "Battery Power")
needed_free_space="$4"
os_name="$5"
insufficient_free_space_for_install_dialog="message goes here $os_name message goes here $available_free_space"
adequate_free_space_for_install_dialog="$os_name message goes here."
no_ac_power="Power message goes here"
if [ "$PowerSource" = "Now drawing from 'Battery Power'" ]; then
jamf displayMessage -message "$no_ac_power"
exit 1
fi
if [[ "$available_free_space" -lt "$needed_free_space" ]]; then
jamf displayMessage -message "$insufficient_free_space_for_install_dialog"
fi
if [[ "$available_free_space" -ge "$needed_free_space" ]]; then
echo "$available_free_space gigabytes found as free space on boot drive. Installing OS."
jamf displayMessage -message "$adequate_free_space_for_install_dialog"
fi
exit 0
Thank you in advance.