Startup script init.d

Begonnen von reacend, 27 Dezember 2012, 10:03:45

Vorheriges Thema - Nächstes Thema

reacend

Hat jemand ein brauchbares init script?

BG,
reacend

Reinerlein

Hi,

also bei mir tut es das unter
http://www.fhemwiki.de/wiki/Linux_Initscript
in abgewandelter Form (Systemabhängige Anpassungen)...

Grüße Reinerlein

Martin Fischer

#! /bin/sh
### BEGIN INIT INFO
# Provides:          fhem
# Required-Start:    $network $remote_fs
# Required-Stop:     $remote_fs $network
# Default-Start:     3 4 5
# Default-Stop:      0 1 2 6
# Short-Description: fhem server for houseautomation
# Description:       Start fhem server for houseautomation
### END INIT INFO
# Author: Name <m_fischer@gmx.de>

fhem_BIN=/usr/bin/fhem.pl
test -x $fhem_BIN || { echo "$fhem_BIN not installed";
        if [ "$1" = "stop" ]; then exit 0;
        else exit 5; fi; }

# Check for existence of needed config file and read it
fhem_CONFIG=/etc/fhem/fhem.conf
test -r $fhem_CONFIG || { echo "$fhem_CONFIG not existing";
        if [ "$1" = "stop" ]; then exit 0;
        else exit 6; fi; }

# Aktionen
case "$1" in
    start)
        echo "Starting fhem "
        $fhem_BIN $fhem_CONFIG
        ;;
    stop)
        echo "Shutting down fhem "
        $fhem_BIN 7072 shutdown
        ;;
    restart)
        $0 stop
        $0 start
        ;;
    status)
        echo -n "Checking for service fhem "
        $fhem_BIN 7072 list
        ps aux|grep fhem.pl
        ;;
    *)
        echo "Usage: $0 {start|stop|status|restart}"
        exit 1
        ;;
esac

exit 0

--
Admin, Developer, Gründungsmitglied des FHEM e.V.