home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 February / PCWorld_2000-02_cd.bin / live / etc / init.d / urandom < prev   
Text File  |  1998-06-21  |  1KB  |  46 lines

  1. #! /bin/sh
  2. #
  3. # urandom    This script saves the random seed between reboots.
  4. #        It is called from the boot, halt and reboot scripts.
  5. #
  6. # Version:    @(#)urandom  1.33  22-Jun-1998  miquels@cistron.nl
  7. #
  8.  
  9. [ -c /dev/urandom ] || exit 0
  10. . /etc/default/rcS
  11.  
  12. case "$1" in
  13.     start|"")
  14.         if [ "$VERBOSE" != no ]
  15.         then
  16.             echo -n "Initializing random number generator... "
  17.         fi
  18.         # Load and then save 512 bytes,
  19.         # which is the size of the entropy pool
  20.         if [ -f /var/run/random-seed ]
  21.         then
  22.             cat /var/run/random-seed >/dev/urandom
  23.         fi
  24.         rm -f /var/run/random-seed
  25.         umask 077
  26.         dd if=/dev/urandom of=/var/run/random-seed count=1 \
  27.             >/dev/null 2>&1 || echo "urandom start: failed."
  28.         umask 022
  29.         [ "$VERBOSE" != no ] && echo "done."
  30.         ;;
  31.     stop)
  32.         # Carry a random seed from shut-down to start-up;
  33.         # see documentation in linux/drivers/char/random.c
  34.         [ "$VERBOSE" != no ] && echo -n "Saving random seed... "
  35.         umask 077
  36.         dd if=/dev/urandom of=/var/run/random-seed count=1 \
  37.             >/dev/null 2>&1 || echo "urandom stop: failed."
  38.         [ "$VERBOSE" != no ] && echo "done."
  39.         ;;
  40.     *)
  41.         echo "Usage: urandom {start|stop}" >&2
  42.         exit 1
  43.         ;;
  44. esac
  45.  
  46.