Skip to content

Instantly share code, notes, and snippets.

@massimomusante
Created June 3, 2018 13:53
Show Gist options
  • Save massimomusante/a7a6976654cb832ca7b523e903b0209e to your computer and use it in GitHub Desktop.
Save massimomusante/a7a6976654cb832ca7b523e903b0209e to your computer and use it in GitHub Desktop.
Listen for shutdown shell script
#! /bin/sh
### BEGIN INIT INFO
# Provides: listen-for-shutdown.py
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
# If you want a command to always run, put it here
# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting listen-4-shutdown.py"
/usr/local/bin/listen-4-shutdown.py &
;;
stop)
echo "Stopping listen-4-shutdown.py"
pkill -f /usr/local/bin/listen-4-shutdown.py
;;
*)
echo "Usage: /etc/init.d/listen-4-shutdown {start|stop}"
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment