Skip to content

Instantly share code, notes, and snippets.

@rogierslag
Created March 20, 2014 14:24
Show Gist options
  • Save rogierslag/9664856 to your computer and use it in GitHub Desktop.
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
### 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