#! /bin/sh
#   /***************************************************************************
#   **                                                                        **
#   **  License                                                               **
#   **  =======                                                               **
#   **                                                                        **
#   **  This software program is released under the terms of a license        **
#   **  agreement between you ('Licensee') and Intel. Do not use or load this **
#   **  software or any associated materials (collectively, the 'Software')   **
#   **  until you have carefully read the full terms and conditions of the    **
#   **  LICENSE located in this software package. By loading or using the     **
#   **  Software, you agree to the terms of this Agreement. If you do not     **
#   **  agree with the terms of this Agreement, do not install or use the     **
#   **  Software.                                                             **
#   ***************************************************************************/
#
#   /***************************************************************************
#   **                                                                        **
#   ** INTEL CORPORATION                                                      **
#   **                                                                        **
#   ** This software is supplied under the terms of the license included      **
#   ** above.  All use of this software must be in accordance with the terms  **
#   ** of that license.                                                       **
#   **                                                                        **
#   **  Abstract:                                                             **
#   **    Initialization script for PROCfgd (SuSE)                          **
#   **                                                                        **
#   ***************************************************************************/
# Copyright (c) 1995-2000 SuSE GmbH Nuernberg, Germany.
#
# Author: Kurt Garloff <feedback@suse.de>
#
# init.d/procfgd
#
#   and symbolic its link
#
# /sbin/procfgd
#
# System startup script for the nessus backend nessusd
#
### BEGIN INIT INFO
# Provides: procfgd
# Required-Start: $network
# Required-Stop:
# Default-Start:  2 3 5
# Default-Stop:   0 1 6
# Description:    Start procfgd
### END INIT INFO

# Source SuSE config
. /etc/rc.config

DAEMON="/usr/sbin/procfgd"
test -x $DAEMON || exit 5

# 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_failed <num>  set local and overall rc status to <num><num>
#      rc_reset         clear local rc status (overall remains)
#      rc_exit          exit appropriate to overall rc status
. /etc/rc.status

start() {
	echo -n "Starting procfgd. "
	## Start daemon with startproc(8). If this fails
	## the echo return value is set appropriate.

	# NOTE: startproc return 0, even if service is 
	# already running to match LSB spec.
	startproc $DAEMON

	# Remember status and be verbose
	rc_status -v
	sleep 1
        #[ -x /usr/sbin/procfg ] && /usr/sbin/procfg -f restore
}

stop() {
	echo -n "Shutting down procfgd. "
	## Stop daemon with killproc(8) and if this fails
	## set echo the echo return value.

	killproc -TERM $DAEMON

	# Remember status and be verbose
	rc_status -v
}

# 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)
	start
	;;
    stop)
	stop
	;;
    restart)
	## Stop the service and regardless of whether it was
	## running or not, start it again.
	stop
	start

	# Remember status and be quiet
	rc_status
	;;
    *)
	echo "Usage: $0 {start|stop|restart}"
	exit 1
	;;
esac
rc_exit
