sysklogd.rc7 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/sbin/openrc-run
  2. # Copyright 1999-2011 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License, v2 or later
  4. extra_started_commands="reload"
  5. depend() {
  6. need clock hostname
  7. provide logger
  8. }
  9. start_daemon() {
  10. local retval=0
  11. local daemon="$1"
  12. local options="$2"
  13. [ -z "${daemon}" ] && return 1
  14. ebegin "sysklogd -> start: ${daemon}"
  15. start-stop-daemon --start --exec /usr/sbin/"${daemon}" \
  16. --pidfile /var/run/"${daemon}".pid -- ${options}
  17. retval=$?
  18. eend ${retval} "Failed to start ${daemon}"
  19. return ${retval}
  20. }
  21. stop_daemon() {
  22. local retval=0
  23. local daemon="$1"
  24. [ -z "${daemon}" ] && return 1
  25. ebegin "sysklogd -> stop: ${daemon}"
  26. # syslogd can be stubborn some times (--retry 15)...
  27. start-stop-daemon --stop --retry 15 --quiet --pidfile /var/run/"${daemon}".pid
  28. retval=$?
  29. eend ${retval} "Failed to stop ${daemon}"
  30. return ${retval}
  31. }
  32. start() {
  33. start_daemon "syslogd" "${SYSLOGD}" || return 1
  34. # klogd do not always start proper if started too early
  35. sleep 1
  36. if ! start_daemon "klogd" "${KLOGD}" ; then
  37. stop_daemon "syslogd"
  38. return 1
  39. fi
  40. return 0
  41. }
  42. stop() {
  43. stop_daemon "klogd" || return 1
  44. stop_daemon "syslogd" || return 1
  45. return 0
  46. }
  47. reload() {
  48. local ret=0
  49. ebegin "Reloading configuration"
  50. start-stop-daemon --signal HUP --pidfile /var/run/syslogd.pid
  51. ret=$((${ret} + $?))
  52. start-stop-daemon --signal USR1 --pidfile /var/run/klogd.pid
  53. ret=$((${ret} + $?))
  54. eend ${ret}
  55. }