File gsad.init.mandriva of Package greenbone-security-assistant

#!/bin/sh
#
# LSB compatible service control script; see http://www.linuxbase.org/spec/
# 
### BEGIN INIT INFO
# Provides:          greenbone-security-assistant
# Required-Start:    $syslog $remote_fs
# Should-Start:      $time ypbind smtp
# Required-Stop:     $syslog $remote_fs
# Should-Stop:       $time ypbind smtp
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: Greenbone Security Assistant
# Description:       Start the Greenbone Security Assistant.
### END INIT INFO
#

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

EXEC="/usr/sbin/gsad"
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
GSAD_CONFIG=/etc/sysconfig/greenbone-security-assistant
test -r $GSAD_CONFIG || { echo "$GSAD_CONFIG not existing";
	if [ "$1" = "stop" ]; then exit 0;
	else exit 6; fi; }

# Read config	
. $GSAD_CONFIG

# Build parameters
[ "$GSA_ADDRESS" ] && PARAMS="--listen=$GSA_ADDRESS"
[ "$GSA_PORT" ] && PARAMS="$PARAMS --port=$GSA_PORT"
[ "$GSA_SSL_PRIVATE_KEY" ] && PARAMS="$PARAMS --ssl-private-key=$GSA_SSL_PRIVATE_KEY"
[ "$GSA_SSL_CERTIFICATE" ] && PARAMS="$PARAMS --ssl-certificate=$GSA_SSL_CERTIFICATE"
[ "$GSA_REDIRECT" ] && [ "$GSA_REDIRECT" == 1 ] && PARAMS="$PARAMS --redirect"
[ "$GSA_REDIRECT_PORT" ] && PARAMS="$PARAMS --rport=$GSA_REDIRECT_PORT"
[ "$ADMINISTRATOR_ADDRESS" ] && PARAMS="$PARAMS --alisten=$ADMINISTRATOR_ADDRESS"
[ "$ADMINISTRATOR_PORT" ] && PARAMS="$PARAMS --aport=$ADMINISTRATOR_PORT"
[ "$MANAGER_ADDRESS" ] && PARAMS="$PARAMS --mlisten=$MANAGER_ADDRESS"
[ "$MANAGER_PORT" ] && PARAMS="$PARAMS --mport=$MANAGER_PORT"

LOCKFILE=/var/lock/subsys/$PROG

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

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

restart() {
    stop
    start
}

reload() {
    echo -n $"Reloading greenbone-security-assistant: "
    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
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|try-restart|reload|force-reload}"
        exit 2
esac