S02klogd 1004 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/sh
  2. DAEMON="klogd"
  3. PIDFILE="/var/run/$DAEMON.pid"
  4. KLOGD_ARGS=""
  5. # shellcheck source=/dev/null
  6. [ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
  7. # BusyBox' klogd does not create a pidfile, so pass "-n" in the command line
  8. # and use "-m" to instruct start-stop-daemon to create one.
  9. start() {
  10. printf 'Starting %s: ' "$DAEMON"
  11. # shellcheck disable=SC2086 # we need the word splitting
  12. start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/sbin/$DAEMON" \
  13. -- -n $KLOGD_ARGS
  14. status=$?
  15. if [ "$status" -eq 0 ]; then
  16. echo "OK"
  17. else
  18. echo "FAIL"
  19. fi
  20. return "$status"
  21. }
  22. stop() {
  23. printf 'Stopping %s: ' "$DAEMON"
  24. start-stop-daemon -K -q -p "$PIDFILE"
  25. status=$?
  26. if [ "$status" -eq 0 ]; then
  27. rm -f "$PIDFILE"
  28. echo "OK"
  29. else
  30. echo "FAIL"
  31. fi
  32. return "$status"
  33. }
  34. restart() {
  35. stop
  36. sleep 1
  37. start
  38. }
  39. case "$1" in
  40. start|stop|restart)
  41. "$1";;
  42. reload)
  43. # Restart, since there is no true "reload" feature.
  44. restart;;
  45. *)
  46. echo "Usage: $0 {start|stop|restart|reload}"
  47. exit 1
  48. esac