Skip to content

Instantly share code, notes, and snippets.

@time-wcrp
Created December 22, 2015 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save time-wcrp/e9afabb94589082953f2 to your computer and use it in GitHub Desktop.
Save time-wcrp/e9afabb94589082953f2 to your computer and use it in GitHub Desktop.
boot-shutdown
#!/bin/bash
# by iiitum
EMAIL=""
function shutdown()
{
EVENT_TIME=$(date +%Y/%m/%d-%H:%M:%S)
ME=`whoami`
SUBJECT="System Shutdown: ${EVENT_TIME}"
BODY="[${ME}] Received a signal to shutdown"
echo ${BODY} | mailx -s "${SUBJECT}" "$EMAIL"
}
function startup()
{
EVENT_TIME=$(date +%Y/%m/%d-%H:%M:%S)
ME=`whoami`
SUBJECT="System Startup: ${EVENT_TIME}"
BODY="[${ME}] Starting..."
echo ${BODY} | mailx -s "${SUBJECT}" "$EMAIL"
}
if [ "$1" == "startup" ]; then
startup
else
shutdown
fi
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>boot.shutdown.service</string>
<key>ProgramArguments</key>
<array>
<string>boot-shutdown.sh</string>
<string>startup</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment