summaryrefslogtreecommitdiff
blob: 1a1f562bcbb3ed4d88735832fc7814860eb5e375 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/sbin/openrc-run
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

export JAVA_HOME=`java-config --jre-home`

checkconfig() {
  if [ ! -r "${GRAYLOG_CONFIG_FILE}" ]; then
    eerror "GRAYLOG_CONFIG_FILE doesn't point to a readable config file"
  fi
}

depend() {
  need net
}

start() {
  checkconfig || return 1

  [ -e `dirname "$GRAYLOG_PID_FILE"` ] || \
    install -d -o${GRAYLOG_USER} -g${GRAYLOG_GROUP} -m750 `dirname "$GRAYLOG_PID_FILE"`

  [ -e "$GRAYLOG_LOG_DIR" ] || \
    install -d -o${GRAYLOG_USER} -g${GRAYLOG_GROUP} -m750 "$GRAYLOG_LOG_DIR"
  
  CLASSPATH="$(java-config -r)"
  CLASSPATH="${CLASSPATH}:$(java-config -d --classpath sigar)"

  ebegin "Starting Graylog"

  start-stop-daemon \
    --start \
    --exec "${JAVA_HOME}/bin/java" \
    --user ${GRAYLOG_USER} \
    --group ${GRAYLOG_GROUP} \
    --env CLASSPATH="${CLASSPATH}" \
    --background \
    --chdir /usr/share/graylog2 \
    --stdout ${GRAYLOG_LOG_DIR}/graylog.stdout.log \
    --stderr ${GRAYLOG_LOG_DIR}/graylog.stderr.log \
    -- ${JAVA_OPTS} -Djava.library.path=`java-config --lib sigar` -classpath "${CLASSPATH}" -jar /usr/share/graylog2/graylog.jar server -f "${GRAYLOG_CONFIG_FILE}" -p "${GRAYLOG_PID_FILE}" ${GRAYLOG_OPTIONS}

  eend $?
}

stop() {
  ebegin "Stopping Graylog"

  start-stop-daemon \
    --stop \
    --pidfile "${GRAYLOG_PID_FILE}"

  eend $?
}