#! /bin/sh

# Installed by Chef => graylog2::default.rb

### BEGIN INIT INFO
# Provides:          graylog2-server
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the graylog2 server
# Description:       starts the graylog2 java server using the graylog2 control script
### END INIT INFO

BINDIR=<%= node[:graylog2][:server_home] %>/bin
NAME=graylog2-server
DESC=graylog2-server

test -x /usr/bin/java || exit 0

set -e

case "$1" in
  start)
    echo -n "Starting $DESC: "
    cd $BINDIR
    ./graylog2ctl start
    echo "...started."
  ;;
  stop)
    echo -n "Stopping $DESC: "
    cd $BINDIR
    ./graylog2ctl stop
    echo "...stopped."
  ;;
  status)
    echo -n "Restarting $DESC: "
    cd $BINDIR
    ./graylog2ctl status
  ;;
  restart)
    echo -n "Restarting $DESC: "
    cd $BINDIR
    ./graylog2ctl restart
    echo "...restarted."
  ;;
  *)
    N=/etc/init.d/$NAME
    echo "Usage: $N {start|stop|restart}" >&2
    exit 1
  ;;
esac

exit 0
#! /bin/sh

# Installed by Chef => graylog2::default.rb

### BEGIN INIT INFO
# Provides:          graylog2-server
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the graylog2 server
# Description:       starts the graylog2 java server using the graylog2 control script
### END INIT INFO

BINDIR=<%= node[:graylog2][:server_home] %>/bin
NAME=graylog2-server
DESC=graylog2-server

test -x /usr/bin/java || exit 0

set -e

case "$1" in
  start)
    echo -n "Starting $DESC: "
    cd $BINDIR
    su - <%= node[:graylog2][:server_user] %> -c "./graylog2ctl start"
    echo "...started."
  ;;
  stop)
    echo -n "Stopping $DESC: "
    cd $BINDIR
    su - <%= node[:graylog2][:server_user] %> -c "./graylog2ctl stop"
    echo "...stopped."
  ;;
  status)
    echo -n "Restarting $DESC: "
    cd $BINDIR
    su - <%= node[:graylog2][:server_user] %> -c "./graylog2ctl status"
  ;;
  restart)
    echo -n "Restarting $DESC: "
    cd $BINDIR
    su - <%= node[:graylog2][:server_user] %> -c "./graylog2ctl restart"
    echo "...restarted."
  ;;
  *)
    N=/etc/init.d/$NAME
    echo "Usage: $N {start|stop|restart}" >&2
    exit 1
  ;;
esac

exit 0

Allow graylog2-server to be started under specified user
Allow graylog2-server to be started under specified user