initd-r1 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/sbin/openrc-run
  2. # Copyright 1999-2017 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. export JAVA_HOME=`java-config --jre-home`
  5. checkconfig() {
  6. if [ ! -r "${GRAYLOG_CONFIG_FILE}" ]; then
  7. eerror "GRAYLOG_CONFIG_FILE doesn't point to a readable config file"
  8. fi
  9. }
  10. depend() {
  11. need net
  12. }
  13. start() {
  14. checkconfig || return 1
  15. [ -e `dirname "$GRAYLOG_PID_FILE"` ] || \
  16. install -d -o${GRAYLOG_USER} -g${GRAYLOG_GROUP} -m750 `dirname "$GRAYLOG_PID_FILE"`
  17. [ -e "$GRAYLOG_LOG_DIR" ] || \
  18. install -d -o${GRAYLOG_USER} -g${GRAYLOG_GROUP} -m750 "$GRAYLOG_LOG_DIR"
  19. ebegin "Starting Graylog"
  20. checkpath -d -o "${GRAYLOG_USER}:${GRAYLOG_GROUP}" -m750 "${GRAYLOG_DATA_DIR}"
  21. checkpath -d -o "${GRAYLOG_USER}:${GRAYLOG_GROUP}" -m750 "${GRAYLOG_DATA_DIR}/data"
  22. checkpath -d -o "${GRAYLOG_USER}:${GRAYLOG_GROUP}" -m750 "${GRAYLOG_DATA_DIR}/data/contentpacks"
  23. checkpath -d -o "${GRAYLOG_USER}:${GRAYLOG_GROUP}" -m750 "${GRAYLOG_DATA_DIR}/data/journal"
  24. start-stop-daemon \
  25. --start \
  26. --exec "${JAVA_HOME}/bin/java" \
  27. --user ${GRAYLOG_USER} \
  28. --group ${GRAYLOG_GROUP} \
  29. --background \
  30. --chdir ${GRAYLOG_INSTALL_DIR} \
  31. --stdout ${GRAYLOG_LOG_DIR}/graylog.stdout.log \
  32. --stderr ${GRAYLOG_LOG_DIR}/graylog.stderr.log \
  33. -- ${JAVA_OPTS} -jar ${GRAYLOG_INSTALL_DIR}/graylog.jar server -f "${GRAYLOG_CONFIG_FILE}" -p "${GRAYLOG_PID_FILE}" ${GRAYLOG_OPTIONS}
  34. eend $?
  35. }
  36. stop() {
  37. ebegin "Stopping Graylog"
  38. start-stop-daemon \
  39. --stop \
  40. --pidfile "${GRAYLOG_PID_FILE}"
  41. eend $?
  42. }