Bug 147660

Summary: No RC script for powerd
Product: [openSUSE] SUSE LINUX 10.0 Reporter: Rob Sessink <rsessink>
Component: BasesystemAssignee: Dr. Werner Fink <werner>
Status: VERIFIED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Enhancement    
Priority: P5 - None    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Other   
Whiteboard:
Found By: Customer Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Rob Sessink 2006-02-02 15:20:53 UTC
There is no rc script for the powerd daemon; So here is a one

 Regards Rob Sessink
---------------------------------------------------------------------
#! /bin/sh
# Copyright (c) 2006
#
# Author: Rob Sessink <rob@animoid-row.org>
#
# System startup script for powerd
#
### BEGIN INIT INFO
# Provides: powerd
# Required-Start: $remote_fs
# X-UnitedLinux-Should-Start:
# Required-Stop: $remote_fs
# Default-Start:  2 3 5
# Default-Stop:  0 1 6
# Description:    Start the powerd daemon
### END INIT INFO

POWERD_BIN=/sbin/powerd
test -x $POWERD || exit 5

POWERD_CONFIG=/etc/powerd.conf
# test for configfile
test -f $POWERD_CONFIG || exit 6

POWERD_PIDFILE=/var/run/powerd.init.pid

# Source SuSE config
. /etc/rc.status

# 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

# First reset status of this service
rc_reset

# Return values acc. to LSB for all commands but status:
# 0 - success
# 1 - generic or unspecified error
# 2 - invalid or excess argument(s)
# 3 - unimplemented feature (e.g. "reload")
# 4 - insufficient privilege
# 5 - program is not installed
# 6 - program is not configured
# 7 - program is not running
#
# 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 powerd daemon"
        ## Start daemon with startproc(8). If this fails
        ## the echo return value is set appropriate.

        startproc -f -p $POWERD_PIDFILE $POWERD_BIN
        rc_status -v
        ;;
    stop)
        echo -n "Shutting down powerd daemon"
        ## Stop daemon with killproc(8) and if this fails
        ## set echo the echo return value.

        killproc -p $POWERD_PIDFILE -TERM $POWERD_BIN

        # Remember status and be verbose
        rc_status -v

        ;;
    try-restart)
        ## Stop the service and if this succeeds (i.e. the
        ## service was running before), start it again.
        ## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
        $0 status >/dev/null &&  $0 restart

        # Remember status and be quiet
        rc_status
        ;;
    restart)
        ## Stop the service and regardless of whether it was
        ## running or not, start it again.
        $0 stop
        $0 start

        # Remember status and be quiet
        rc_status
        ;;
    force-reload)
        ## Signal the daemon to reload its config. Most daemons
        ## do this on signal 1 (SIGHUP).
        ## If it does not support it, restart.
        $0 try-restart
        rc_status
        ;;
    reload)
        $0 try-restart
        rc_status
        ;;
    status)
        echo -n "Checking for service powerd "

        # 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

        checkproc -p $POWERD_PIDFILE $POWERD_BIN

        rc_status -v
        ;;
    *)
        echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
        exit 1
        ;;
esac
rc_exit
Comment 1 Dr. Werner Fink 2006-02-07 15:36:25 UTC
I do not see that the powerd uses /var/run/powerd.init.pid
as pid file. Do you have patched your powerd or are you
using an other version?
Comment 2 Dr. Werner Fink 2006-02-07 16:49:42 UTC
I've add pid file support and an appropiate rc script.
The rc script has to depend on $syslog due to the
fact that the powerd of the sysvinit package requires
syslog.
Comment 3 Rob Sessink 2006-02-13 09:01:37 UTC
I was on vacation last week; so sorry for the late reply. It was my mistake to include the /var/run/powerd.init.pid directive in the rc script, but the resolution to add pid support to powerd is probably the best solution. I am willing to test the PID support in powerd if you have a diff/source available.

  Regards Rob Sessink
Comment 4 Dr. Werner Fink 2006-02-13 11:44:30 UTC
Will be part of the next SuSE Linux release and OpenSuSE.
Comment 5 Rob Sessink 2006-02-13 11:51:28 UTC
Ah oke. thank you