Linux Initscript

Aus FHEMWiki
Version vom 15. Oktober 2013, 13:44 Uhr von Ph1959de (Diskussion | Beiträge) (Interwiki-Link korrigiert)

As I have been searching for such script for a while, I'd like to insert it here for other's convenience.

Provided for SuSE 11.4 but can of course easily be adapted to other distributions.

#! /bin/sh
 # Copyright (c) 2011 Wolfram Plettscher
 # All rights reserved
 #
 # Author: Wolfram Plettscher, 2011
 #
 # /etc/init.d/fhem
 #
 ### BEGIN INIT INFO
 # Provides:    fhem
 # Required-Start:
 # Required-Stop:
 # Default-Start:  3 5
 # Default-Stop:  0 1 2 6
 # Short-Description: starts FHEM house automation server
 # Description:    during start it also reconfigures /dev/ttyACM0 to rwrwrw rights
 #          (this is hardcoded for busware CUL device)
 #          Last maintained for SuSE 11.4
 #
 # Installation:
 # - copy this file to /etc/init.d
 # - chmod 744 /etc/init.d/fhem
 # - ln -s /etc/init.d/fhem /sbin/fhem
 # - enable and edit in YAST system services
 ### END INIT INFO
 
 case "$1" in
  start)
   echo "Start $0"
   chmod 666 /dev/ttyACM0
   /usr/bin/fhem.pl /etc/fhem.cfg
   ;;
  stop)
   echo "Stop $0"
   /usr/bin/fhem.pl 7072 shutdown
   ;;
  status)
   cnt=`ps -ef | grep "fhem.pl" | grep -v grep | wc -l`
   if [ "$cnt" -eq "0" ] ; then
    echo "$0 is not running"
   else
    echo "$0 is running"
   fi
   ;;
  *)
   echo "Usage: $0 {start|stop|status}"
  exit 1
 esac
 exit 0

Insipired by Qnap_NAS Thanks to ThostenS

Wolfram May 5th, 2011