updated on Thu Jan 19 16:10:29 UTC 2012
[aur-mirror.git] / graylog2-server / graylog2.rc.d
blob5c73508b10fe67a25bf67e6daa5450e036caecc8
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
5 . /etc/conf.d/graylog2
7 PIDFILE="/tmp/graylog2.pid"
9 check_pid() {
10 [ ! -f "$PIDFILE" ] && return 1
11 local PID=$(cat "$PIDFILE" 2> /dev/null)
12 [ -z "$PID" ] && return 1
13 if [ ! -d "/proc/$PID" ]; then
14 rm -f "$PIDFILE" 2> /dev/null
15 return 1
17 return 0
20 kill_pid() {
21 if check_pid; then
22 local PID=$(cat "$PIDFILE" 2> /dev/null)
23 kill $PID &> /dev/null
24 local RET=$?
25 check_pid
26 return $RET
28 return 1
31 wait_pid() {
32 while check_pid; do sleep 1; done
35 case "$1" in
36 start)
37 stat_busy "Starting graylog2"
38 check_pid || $JAVA_HOME/bin/java -jar $JAVA_OPTS /usr/lib/graylog2-server.jar > /dev/null &
39 if [ $? -gt 0 ]; then
40 stat_fail
41 else
42 add_daemon graylog2
43 stat_done
46 stop)
47 stat_busy "Stopping graylog2"
48 if ! kill_pid; then
49 stat_fail
50 else
51 rm_daemon graylog2
52 stat_done
55 restart)
56 $0 stop
57 wait_pid
58 $0 start
61 echo "usage: $0 {start|stop|restart}"
62 esac
63 exit 0