#!/bin/sh # description: Start or stop the fhem server # ### BEGIN INIT INFO # Provides: fhz # Required-Start: $network $syslog $remote_fs # Required-Stop: $network $remote_fs # Default-Start: 2 3 5 # Default-Stop: 0 1 6 # Description: Start or stop the fhz server ### END INIT INFO fhz=/data/Homeautomation/fhem/fhem.pl maintain=/data/Homeautomation/scripts/maintain_logs.sh conf=/data/Homeautomation/fhem-conf/fhem.conf port=7072 case "$1" in 'start') echo "Log maintenance..." $maintain reset echo "Starting fhem..." $fhz $conf RETVAL=$? ;; 'stop') echo "Stopping fhem..." $fhz $port "shutdown" echo "Log maintenance..." $maintain persist RETVAL=$? ;; 'status') cnt=`ps -ef | grep "fhem.pl" | grep -v grep | wc -l` if [ "$cnt" -eq "0" ] ; then echo "fhem is not running" else echo "fhem is running" fi ;; *) echo "Usage: $0 { start | stop | status }" RETVAL=1 ;; esac exit $RETVAL