Sophie

Sophie

distrib > Mandriva > 9.1 > i586 > by-pkgid > 8c6202abd5c23d52fed280e28dc23b0a > files > 39

initscripts-7.06-12.3.91mdk.i586.rpm

#!/bin/bash
#
# random	Script to snapshot random state and reload it at boot time.
#
# Author:       Theodore Ts'o <tytso@mit.edu>
#
# chkconfig: 2345 20 80
# description: Saves and restores system entropy pool for higher quality \
#              random number generation.

. /etc/init.d/functions

random_seed=/var/lib/random-seed

# See how we were called.
case "$1" in
  start)
	# Carry a random seed from start-up to start-up
	# Load and then save 512 bytes, which is the size of the entropy pool
	if [ -f $random_seed ]; then
		cat $random_seed >/dev/urandom
	else
		touch $random_seed
	fi
	action "Initializing random number generator: " /bin/true
	chmod 600 $random_seed
	dd if=/dev/urandom of=$random_seed count=1 bs=512 2>/dev/null
	touch /var/lock/subsys/random

	;;
  stop)
	# Carry a random seed from shut-down to start-up
	# Save 512 bytes, which is the size of the entropy pool
	touch $random_seed
	chmod 600 $random_seed
	action "Saving random seed: " dd if=/dev/urandom of=$random_seed count=1 bs=512 2>/dev/null
	
	rm -f /var/lock/subsys/random
	;;
  status)
	# this is way overkill, but at least we have some status output...
	if [ -c /dev/random ] ; then
		gprintf "The random data source exists\n"
	else
		gprintf "The random data source is missing\n"
	fi
	;;
  restart|reload)
	# do not do anything; this is unreasonable
	:
	;;
  *)
	# do not advertise unreasonable commands that there is no reason
	# to use with this device
	gprintf "Usage: %s\n" "$(basename $0) {start|stop|status|restart|reload}"
	exit 1
esac

exit 0