Created
December 22, 2015 03:04
-
-
Save time-wcrp/e9afabb94589082953f2 to your computer and use it in GitHub Desktop.
boot-shutdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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