LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File LCDd of Package LCDproc (Project home:sagiben)

#! /bin/sh

### BEGIN INIT INFO
# Provides:          LCDd
# Required-Start:    $remote_fs
# Required-Stop:     $remote_fs
# Default-Start:     2 3 5
# Default-Stop:
# Short-Description: drives a LC-Display via lcdproc
# Description:       Start the LCDd monitor
# X-UnitedLinux-Default-Enabled: yes
### END INIT INFO

LCDD_BIN=/usr/sbin/LCDd

# Source configuration file.  This should define the shell variable smartd_opts
    
RETVAL=0

# Shell functions sourced from /etc/rc.status:
#      rc_check         check and set local and overall rc status
#      rc_status        check and set local and overall rc status
#      rc_status -v     ditto but be verbose in local rc status
#      rc_status -v -r  ditto and clear the local rc status
#      rc_failed        set local and overall rc status to failed
#      rc_reset         clear local rc status (overall remains)
#      rc_exit          exit appropriate to overall rc status
. /etc/rc.status

# First reset status of this service
rc_reset

# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - misc error
# 2 - invalid or excess args
# 3 - unimplemented feature (e.g. reload)
# 4 - insufficient privilege
# 5 - program not installed
# 6 - program not configured
#
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signalling is not supported) are
# considered a success.
case "$1" in
    start)
        echo -n "Starting LCDd "
        ## Start daemon with startproc(8). If this fails
        ## the echo return value is set appropriate.
        
        # startproc should return 0, even if service is
        # already running to match LSB spec.
        startproc $LCDD_BIN 
        
        # Remember status and be verbose
        rc_status -v
        ;;
    stop)
        echo -n "Shutting down LCDd "
        killproc -TERM $LCDD_BIN
        
        # Remember status and be verbose
        rc_status -v
        ;;
    try-restart|condrestart)
        ## Do a restart only if the service was active before.
        ## Note: try-restart is now part of LSB (as of 1.9).
        ## RH has a similar command named condrestart.
        if test "$1" = "condrestart"; then
                echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
        fi
        $0 status
        if test $? = 0; then
                $0 restart 
        else 
                rc_reset	# Not running is not a failure.
        fi
        # Remember status and be quiet
        rc_status
        ;;
    restart | force-reload)
        $0 stop
        $0 start
        ;;
    reload)
	## Like force-reload, but if daemon does not support
	## signaling, do nothing (!)
        rc_failed 3
        rc_status -v
        ;;
    status)
        echo -n "Checking for service LCDd "
        ## Check status with checkproc(8), if process is running
        ## checkproc will return with exit status 0.
        
        # Status has a slightly different for the status command:
        # 0 - service running
        # 1 - service dead, but /var/run/  pid  file exists
        # 2 - service dead, but /var/lock/ lock file exists
        # 3 - service not running
        
        # NOTE: checkproc returns LSB compliant status values.
        checkproc $LCDD_BIN
        rc_status -v
        ;;
    probe)
        ## Optional: Probe for the necessity of a reload, print out the
        ## argument to this init script which is required for a reload.
        ## Note: probe is not (yet) part of LSB (as of 1.2)

        test $SMARTD_CONFIG -nt /var/run/LCDd.pid && echo reload
        ;;
    *)
        
        exit 1
        ;;
esac

rc_exit