Skip to content

Instantly share code, notes, and snippets.

@stojg
Last active August 29, 2015 14:05
Show Gist options
  • Save stojg/d1cbb8536e5a447e1f3a to your computer and use it in GitHub Desktop.
Save stojg/d1cbb8536e5a447e1f3a to your computer and use it in GitHub Desktop.
graylog2-web-interface init
#!/bin/bash
### BEGIN INIT INFO
# Provides: graylog2-web
# Required-Start: $graylog2
# Required-Stop: $graylog2
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts graylog2-web
# Description: Starts graylog2-web using start-stop-daemon
### END INIT INFO
NOHUP=`which nohup`
NAME=graylog2-web
GL_HOME=/opt/graylog2-web-interface/bin
PIDFILE=/var/run/$NAME.pid
CMD=$1
start() {
echo "Starting $NAME ..."
PID=`$NOHUP $GL_HOME/graylog2-web-interface -Dhttp.port=80 > /dev/null 2>&1 & echo $!`
if [ -z $PID ]; then
printf "%s\n" "Fail"
else
echo $PID > $PIDFILE
printf "%s\n" "Ok"
fi
}
stop() {
PID=`cat $PIDFILE`
echo "Stopping $NAME ($PID) ..."
if [ -f $PIDFILE ]; then
kill $PID
printf "%s\n" "Ok"
rm -f $PIDFILE
else
printf "%s\n" "pidfile not found"
fi
}
restart() {
echo "Restarting $NAME..."
stop
start
}
case "$CMD" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo "Usage $0 {start|stop|restart}"
RETVAL=1
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment