random 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/sh
  2. ########################################################################
  3. # Begin random
  4. #
  5. # Description : Seed /dev/urandom
  6. #
  7. # Author : Larry Lawrence
  8. #
  9. # Version : LFS 7.0
  10. #
  11. ########################################################################
  12. ### BEGIN INIT INFO
  13. # Provides: random
  14. # Required-Start: $local_fs
  15. # Should-Start:
  16. # Required-Stop: $local_fs
  17. # Should-Stop:
  18. # Default-Start: 2 3 4 5
  19. # Default-Stop: 0 1 6
  20. # Short-Description: Initialises /dev/urandom
  21. # Description: Initialises /dev/urandom from a seed stored in /var/tmp.
  22. # X-LFS-Provided-By: BLFS / LFS 7.0
  23. ### END INIT INFO
  24. . /etc/rc.d/functions
  25. #$LastChangedBy: bdubbs $
  26. #$Date: 2011-12-06 05:56:33 +0000 (Tue, 06 Dec 2011) $
  27. case "$1" in
  28. start)
  29. log_info_msg "Initializing kernel random number generator..."
  30. if [ -f /var/tmp/random-seed ]; then
  31. /bin/cat /var/tmp/random-seed >/dev/urandom
  32. fi
  33. /bin/dd if=/dev/urandom of=/var/tmp/random-seed count=1 &>/dev/null
  34. evaluate_retval
  35. ;;
  36. stop)
  37. log_info_msg "Saving random seed..."
  38. /bin/dd if=/dev/urandom of=/var/tmp/random-seed count=1 &>/dev/null
  39. evaluate_retval
  40. ;;
  41. *)
  42. echo "Usage: $0 {start|stop}"
  43. exit 1
  44. ;;
  45. esac
  46. # End /etc/init.d/random