puppetserver.initd 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/sbin/openrc-run
  2. # Copyright 1999-2015 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. extra_commands="checkconfig reload"
  5. LOGDIR="/var/log/puppetlabs/puppetserver"
  6. RUNDIR="/run/puppetlabs/puppetserver"
  7. checkconfig() {
  8. if [ ! -x $JAVA_BIN ]; then
  9. eerror "Missing JAVA_BIN."
  10. eend 1
  11. fi
  12. if [ ! -d $INSTALL_DIR ]; then
  13. eerror "Missing INSTALL_DIR."
  14. eend 1
  15. fi
  16. if [ ! -e $BOOTSTRAP_CONFIG ]; then
  17. eerror "Missing BOOTSTRAP_CONFIG."
  18. eend 1
  19. fi
  20. if [ ! -e $CONFIG ]; then
  21. eerror "Missing CONFIG."
  22. eend 1
  23. fi
  24. if [ ! -n $USER ]; then
  25. eerror "Missing USER."
  26. eend 1
  27. fi
  28. if [ ! -n $GROUP ]; then
  29. eerror "Missing GROUP."
  30. eend 1
  31. fi
  32. checkpath -d -m 0755 "${LOGDIR%/*}"
  33. checkpath -d -m 0755 "${RUNDIR%/*}"
  34. checkpath -d -m 0700 -o "${USER}:${GROUP}" "${LOGDIR}"
  35. checkpath -d -m 0755 -o "${USER}:${GROUP}" "${RUNDIR}"
  36. JAVA_ARGS="${JAVA_ARGS} -cp '${INSTALL_DIR}/puppet-server-release.jar' clojure.main -m puppetlabs.trapperkeeper.main --config ${CONFIG} -b '${BOOTSTRAP_CONFIG}'"
  37. EXEC="${JAVA_BIN} -XX:OnOutOfMemoryError=\"kill -9 %p\" -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/puppetlabs/puppetserver -Djava.security.egd=/dev/urandom ${JAVA_ARGS}"
  38. }
  39. start() {
  40. checkconfig || return 1
  41. ebegin "Starting Puppet Server"
  42. start-stop-daemon --start -u "${USER}" -g "${GROUP}" \
  43. -m --pidfile "${RUNDIR}/puppetserver.pid" \
  44. -b --exec "/bin/bash" \
  45. -- -c "exec ${EXEC} >> ${LOGDIR}/daemon.log 2>&1"
  46. local retval=$?
  47. if [ $retval -ne 0 ]; then
  48. ewarn "Error starting puppetserver."
  49. fi
  50. eend $retval
  51. }
  52. stop() {
  53. ebegin "Stopping Puppet Server"
  54. start-stop-daemon --stop --pidfile "${RUNDIR}/puppetserver.pid"
  55. eend $?
  56. }
  57. reload() {
  58. ebegin "Reloading Puppet Server"
  59. start-stop-daemon --signal HUP --pidfile "${RUNDIR}/puppetserver.pid"
  60. eend $?
  61. }