1
0

rngd.init 599 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. exec sh $0 start
  10. ;;
  11. start)
  12. devnode=""
  13. for node in hw_random hwrandom i810_rng hwrng; do
  14. if [ -e /dev/$node ]; then
  15. devnode=/dev/$node
  16. break
  17. fi
  18. done
  19. if [ -z "$devnode" ]; then
  20. echo "no hardware RNG found, falling back to /dev/urandom"
  21. devnode=/dev/urandom
  22. fi
  23. /usr/sbin/rngd -b -r $devnode
  24. ;;
  25. stop)
  26. kill $(pgrep -f /usr/sbin/rngd)
  27. ;;
  28. restart)
  29. sh $0 stop
  30. sleep 1
  31. sh $0 start
  32. ;;
  33. *)
  34. echo "Usage: $0 {start | stop | restart}"
  35. exit 1
  36. ;;
  37. esac
  38. exit $?