LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File init.d-graylog-web-interface-suse of Package graylog2-web-interface (Project home:porscheinformatik:monitoring)

#!/bin/sh
### BEGIN INIT INFO
# Provides:          FOO
# Required-Start:    $syslog $remote_fs
# Should-Start:      $time ypbind smtp
# Required-Stop:     $syslog $remote_fs
# Should-Stop:       ypbind smtp
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: FOO XYZ daemon providing ZYX
# Description:       Start FOO to allow XY and provide YZ
### END INIT INFO

# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
SERVICE_NAME="Graylog2 Web Interface"

# Check for existence of needed config file and read it
GRAYLOG2_CONFIG=/etc/sysconfig/graylog2-web-interface
test -r $GRAYLOG2_CONFIG || { echo "$GRAYLOG2_CONFIG not existing";
	if [ "$1" = "stop" ]; then exit 0;
	else exit 6; fi; }
. $GRAYLOG2_CONFIG

CMD_LINE=${WEB_HOME}/bin/graylog2-web-interface
PID_FILE=/var/run/graylog2/web-interface.pid
. /etc/rc.status
# Reset status of this service
rc_reset

export GRAYLOG2CTL_DIR GRAYLOG2_SERVER_JAR GRAYLOG2_CONF GRAYLOG2_PID GRAYLOG2_USER LOG4J LOG_FILE

is_running()
{
    if [ ! -f "$PID_FILE" ]; then
        return 3
    elif kill -0 "$(cat $PID_FILE)" >/dev/null 2>&1; then
        return 0
    fi
    return 1
}

status()
{
    return $1
}

case "$1" in
start)
	echo -n "Starting  ${SERVICE_NAME}"
	if is_running; then
	    echo "... already running"
	else
	    /sbin/startproc -u $WEB_USER -s $CMD_LINE -Dconfig.file=${WEB_CONF} -Dlogger.file=${WEB_LOG_CONF} -Dpidfile.path=${PID_FILE} -Dhttps.keyStore=${WEB_KEYSTORE} ${WEB_CMD_PARAMS}
        RET=$?

        if [ $RET = 7 ]; then
            for i in {0..10}; do
                test -f "$PID_FILE" && RET=0 && break
                sleep 0.5
            done
        fi
        status $RET
    fi
	rc_status -v
	;;
stop)
	echo -n "Shutting down ${SERVICE_NAME} "
	test ! -f "$PID_FILE" || kill -TERM "$(cat $PID_FILE)"
	rc_status -v
	rm "$PID_FILE" 2>/dev/null
	;;
restart|reload)
	$0 stop
	$0 start
	rc_status
	;;
status)
	echo -n "Checking for service ${SERVICE_NAME} "
	is_running
	rc_status -v
	;;
*)
	echo "Usage: $0 {start|stop|status|restart|reload}"
	exit 1
	;;
esac
rc_exit