rngd.init 673 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/sh
  2. #PKG rng-tools
  3. #INIT 60
  4. . /etc/rc.conf
  5. case $1 in
  6. autostop) ;;
  7. autostart)
  8. test x"${rngd:-NO}" = x"NO" && exit 0
  9. test x"$rngd" = x"DAEMON" && test -x /bin/mksh && exec mksh -T- $0 start
  10. exec sh $0 start
  11. ;;
  12. start)
  13. devnode=""
  14. for node in hw_random hwrandom i810_rng hwrng; do
  15. if [ -e /dev/$node ]; then
  16. devnode=/dev/$node
  17. break
  18. fi
  19. done
  20. if [ -z "$devnode" ]; then
  21. echo "no hardware RNG found, falling back to /dev/urandom"
  22. devnode=/dev/urandom
  23. fi
  24. /usr/sbin/rngd -b -r $devnode
  25. ;;
  26. stop)
  27. kill $(pgrep -f /usr/sbin/rngd)
  28. ;;
  29. restart)
  30. sh $0 stop
  31. sleep 1
  32. sh $0 start
  33. ;;
  34. *)
  35. echo "Usage: $0 {start | stop | restart}"
  36. exit 1
  37. ;;
  38. esac
  39. exit $?