LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File openvasmd.init.fedora of Package openvas-manager (Project openSUSE:12.1)

#!/bin/sh
#
# openvas-manager    This starts and stops the OpenVAS Manager.
#
# chkconfig:   35 75 25
# description: This starts and stops the OpenVAS Manager.
# processname: /usr/sbin/openvasmd
# config:      /etc/openvas/openvasmd.conf
# pidfile:     /var/run/openvasmd.pid
#
### BEGIN INIT INFO
# Provides: $openvas-manager
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

EXEC="/usr/sbin/openvasmd"
PROG=$(basename $EXEC)

# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
test -x $EXEC || { echo "$EXEC not installed"; 
	if [ "$1" = "stop" ]; then exit 0;
	else exit 5; fi; }

# Check for existence of needed config file
OPENVASMD_CONFIG=/etc/sysconfig/openvas-manager
test -r $OPENVASMD_CONFIG || { echo "$OPENVASMD_CONFIG not existing";
	if [ "$1" = "stop" ]; then exit 0;
	else exit 6; fi; }

# Read config	
. $OPENVASMD_CONFIG

# Build parameters
[ "$DATABASE_FILE" ]   && PARAMS="--database="$DATABASE_FILE
[ "$MANAGER_ADDRESS" ] && PARAMS="$PARAMS --listen=$MANAGER_ADDRESS"
[ "$MANAGER_PORT" ]    && PARAMS="$PARAMS --port=$MANAGER_PORT"
[ "$SCANNER_ADDRESS" ] && PARAMS="$PARAMS --slisten=$SCANNER_ADDRESS"
[ "$SCANNER_PORT" ]    && PARAMS="$PARAMS --sport=$SCANNER_PORT"

LOCKFILE=/var/lock/subsys/$PROG

start() {
    echo -n $"Starting openvas-manager: "
    daemon $EXEC $PARAMS
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch $LOCKFILE
    return $RETVAL
}

stop() {
    echo -n $"Stopping openvas-manager: "
    killproc $PROG
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
    return $RETVAL
}

restart() {
    stop
    start
}

reload() {
    echo -n $"Reloading openvas-manager: "
    killproc $PROG -HUP
    RETVAL=$?
    echo
    return $RETVAL
}

force_reload() {
    restart
}

fdr_status() {
    status $PROG
}

case "$1" in
    start|stop|restart|reload)
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        fdr_status
        ;;
    condrestart|try-restart)
        [ ! -f $LOCKFILE ] || restart
        ;;
    update)
        ## Update the NVT cache and exit.

        $EXEC $PARAMS --update
        ;;
    rebuild)
        ## Rebuild the NVT cache and exit.

	$EXEC $PARAMS --rebuild
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|try-restart|reload|force-reload|update|rebuild}"
        exit 2
esac