Created
January 21, 2014 16:15
-
-
Save amonks/8543044 to your computer and use it in GitHub Desktop.
Put this file in /etc/init.d/ and edit {THING-TO-LAUNCH} as appropriate. You can run `sudo update-rc.d {THIS-FILE'S-NAME} defaults` to `start` at boot and `stop` at 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/sh | |
# /etc/init.d/{THING-TO-LAUNCH} | |
### BEGIN INIT INFO | |
# Provides: {THING-TO-LAUNCH} | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Simple script to start a program at boot | |
# Description: Simple, conventional, practical launch script. By Andrew Monks. | |
### END INIT INFO | |
# run `sudo update-rc.d {THIS-FILE'S-NAME} defaults` to `start` at boot and `stop` at shutdown. | |
# Carry out specific functions when asked to by the system | |
case "$1" in | |
start) | |
echo "Starting {THING-TO-LAUNCH}" | |
# run application you want to start | |
# runs as root by default, hence the `su` | |
# /usr/bin/{THING-TO-LAUNCH} # on its own works if you'd like to run as root. | |
su pi -c '/usr/bin/{THING-TO-LAUNCH}' # or whatever | |
;; | |
stop) | |
echo "Stopping {THING-TO-LAUNCH}" | |
# kill application you want to stop | |
su pi -c 'killall {THING-TO-LAUNCH}' # or whatever | |
;; | |
*) | |
echo "Usage: /etc/init.d/{THING-TO-LAUNCH} {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