S21rngd 894 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/sh
  2. NAME="rngd"
  3. DAEMON="/usr/sbin/${NAME}"
  4. DAEMON_ARGS=""
  5. CFG_FILE="/etc/default/${NAME}"
  6. PID_FILE="/var/run/${NAME}.pid"
  7. # Read configuration variable file if it is present
  8. [ -r "${CFG_FILE}" ] && . "${CFG_FILE}"
  9. start()
  10. {
  11. printf "Starting ${NAME}: "
  12. start-stop-daemon -S -q -x "${DAEMON}" -- ${DAEMON_ARGS}
  13. [ $? = 0 ] && echo "OK" || echo "FAIL"
  14. }
  15. stop()
  16. {
  17. printf "Stopping ${NAME}: "
  18. # This daemon does not exit properly with the default TERM signal unless
  19. # it's forced to work by something reading /dev/random. Killing it and
  20. # removing its PID file is more straightforward.
  21. if start-stop-daemon -K -q -s KILL -p "${PID_FILE}" -n "${NAME}"; then
  22. rm -f "${PID_FILE}"
  23. echo "OK"
  24. else
  25. echo "FAIL"
  26. fi
  27. }
  28. case "$1" in
  29. start)
  30. start
  31. ;;
  32. stop)
  33. stop
  34. ;;
  35. restart|reload)
  36. stop
  37. start
  38. ;;
  39. *)
  40. echo "Usage: $0 {start|stop|restart|reload}" >&2
  41. exit 1
  42. ;;
  43. esac