Skip to content

Instantly share code, notes, and snippets.

@inC3ASE
Created October 14, 2016 02:04
Show Gist options
  • Save inC3ASE/2ea44b35747f824ed0a024dbad9c54da to your computer and use it in GitHub Desktop.
Save inC3ASE/2ea44b35747f824ed0a024dbad9c54da to your computer and use it in GitHub Desktop.
libexec
#!/bin/sh
#
# Initialize...
#
PATH=/bin:/usr/bin:/sbin:/usr/sbin
SI_PATH=/System/Library/StartupItems
MSG="Shutting down due to power loss!"
logger -i -p daemon.emerg -t UPS "${MSG}"
#
# Take the system down.
#
if [[ -n $1 && "WaitForUPS" == $1 ]] ; then
#
# Wait for UPS to take the system down abruptly and unexpectedly.
#
shutdown -hu now "${MSG}"
else
#
# Gently shutdown the system immediately.
#
shutdown -h now "${MSG}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment