Created
March 20, 2014 14:24
-
-
Save rogierslag/9664856 to your computer and use it in GitHub Desktop.
This is how you can create a daemon of a simple program on rPi
This file contains 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
### BEGIN INIT INFO | |
# Provides: pi-radio | |
# Required-Start: autofs $all | |
# Required-Stop: $remote_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Starts and stops the Raspberry Radio | |
# Description: Starts and stops the Raspberry Radio | |
### END INIT INFO | |
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
DAEMON=/usr/local/bin/pi-radio | |
NAME=pi-radio | |
DESC="Raspberry Radio" | |
test -x $DAEMON || exit 0 | |
. /lib/lsb/init-functions | |
set -e | |
case "$1" in | |
start) | |
echo -n "Starting $DESC: " | |
start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid --background --make-pidfile --exec $DAEMON | |
echo "$NAME." | |
;; | |
stop) | |
echo -n "Stopping $DESC: " | |
start-stop-daemon --stop --oknodo --quiet --pidfile /var/run/$NAME.pid | |
echo "$NAME." | |
;; | |
restart) | |
$0 stop | |
sleep 1 | |
$0 start | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart}" >&2 | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment