cheers,
Rob
Code: Select all
#!/bin/sh
### BEGIN INIT INFO
# Provides: qlcplus
# Required-Start: $network $remote_fs $syslog $time
# Required-Stop: $network $remote_fs $syslog $time
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Q Light Controller Plus
# Description: Q Light Controller Plus
### END INIT INFO
NAME=qlcplus
DESC="Q Light Controller Plus"
BINARY=/usr/bin/qlcplus
test -x $BINARY || exit 0
. /lib/lsb/init-functions
QLCPLUS_OPTS="--web --operate --overscan"
export USER=root # change to 'pi' or another unprivileged user
export HOME=$(getent passwd "$USER" | cut -d: -f6)
cd $HOME
autostart="$HOME/.qlcplus/autostart.qxw"
if [ -e "$autostart" ]; then
QLCPLUS_OPTS="$QLCPLUS_OPTS --open $autostart"
fi
# if NTP hasn't done its job already, set the date to modern age...
CURRDATE=`date +%Y`
if [ "$CURRDATE" -lt "2016" ]; then
date +%Y%m%d -s "20160415"
fi
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
start-stop-daemon --start --background --oknodo --quiet -m --pidfile /var/run/qlcplus.pid --chuid "$USER" --exec $BINARY -- $QLCPLUS_OPTS >/dev/null
log_end_msg "$?"
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
start-stop-daemon --stop --oknodo --quiet --exec $BINARY --pidfile /var/run/qlcplus.pid
log_end_msg "$?"
;;
reload)
log_daemon_msg "Reloading $DESC" "$NAME"
start-stop-daemon --stop --signal HUP --exec $BINARY --pidfile /var/run/qlcplus.pid
log_end_msg "$?"
;;
restart|force-reload)
$0 stop
sleep 8
$0 start
;;
status)
status_of_proc $BINARY "$NAME"
exit $?
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload|reload|status}" >&2
exit 1
;;
esac
exit 0