#!/bin/sh
### BEGIN INIT INFO
# Provides:          Display for WLANThermo
# Required-Start:    $remote_fs $syslog 
# Required-Stop:     $remote_fs $syslog
# Default-Start:     
# Default-Stop:      0 1 6
# Short-Description: Start/stop Display.
# Description:       This script starts/stops the Display.
### END INIT INFO

DAEMON=/usr/bin/python
ARGS=/usr/sbin/wlt_2_lcd_204.py
DAEMON_NAME=WLANThermoDIS


# This next line determines what user the script runs as.
# Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python.
DAEMON_USER=root

# The process ID of the script when it runs is stored here:
PIDFILE=/var/run/$DAEMON_NAME.pid

. /lib/lsb/init-functions
 
do_start () {
log_daemon_msg "Starting system $DAEMON_NAME daemon"
/sbin/start-stop-daemon --start --pidfile $PIDFILE \
        --user root --group root \
        -b --make-pidfile \
        --chuid root \
        --exec $DAEMON $ARGS
log_end_msg $?
}
do_stop () {
log_daemon_msg "Stopping system $DAEMON_NAME daemon"
if [ ! -f /var/www/tmp/display/wd ]; then
    # Wenn noch keine halt oder reboot Meldung am Display ausgegeben wurde lösche es!
    echo " ; ; ; ;" > /var/www/tmp/display/wd
    sleep 3
fi
 /sbin/start-stop-daemon --stop --pidfile $PIDFILE --verbose
log_end_msg $?
}

case "$1" in
 
start|stop)
do_${1}
;;
 
restart|reload|force-reload)
do_stop
do_start
;;
 
status)
status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $?
;;
*)
echo "Usage: /etc/init.d/$DEAMON_NAME {start|stop|restart|status}"
exit 1
 ;;
 
esac
exit 0
