Graylog2 Server start script

Das folgende Start Script startet einen Graylog2 Server unter ubunut:

/etc/init.d/graylog2-server

#!/bin/sh
#

### BEGIN INIT INFO
# Provides: graylog2-server
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start graylog2-server at boot time
# Description: Controls the graylog2-server.
### END INIT INFO

JAVA_CMD=java
PID_FILE=/tmp/graylog2.pid
GRAYLOG2_SERVER_HOME=/opt/graylog2-server

start() {
echo “Starting graylog2-server …”
$JAVA_CMD -jar $GRAYLOG2_SERVER_HOME/graylog2-server.jar > /var/log/graylog2.log 2>&1 &
echo “ startet (‘cat “$PID_FILE”‘).”
}

stop() {
PID=`cat $PID_FILE`
echo “Stopping graylog2-server ($PID) …”
kill $PID
echo “stopped.”
}

restart() {
echo “Restarting graylog2-server …”
stop
sleep 0.5
start
}

case “$1” in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo “Usage $0 {start|stop|restart}” >&2
exit 1
esac
exit 0