Previous Page | Next Page

  1. Introduction
  2. Boot Process
  3. Init and System Initialization
  4. rc.sysinit script
  5. rc script
  6. functions script
  7. Services
  8. apm daemon
  9. network startup
  10. The network script file
  11. The network-functions file
  12. Portmap startup
  13. Random initialization
  14. Syslog initialization
  15. Gated
  16. Atd
  17. cron initialization
  18. pcmcia
  19. inetd daemon
  20. named daemon
  21. lpd daemon
  22. mars-nwe
  23. netfs startup
  24. dhcpd daemon
  25. autofs daemon
  26. keytable daemon
  27. sendmail daemon
  28. gpm daemon
  29. httpd daemon
  30. xfs startup
  31. smb startup
  32. innd startup
  33. linuxconf startup
  34. rc.local script
  35. Init, Getty, Login
  36. The shell
  37. Shutting down
  38. X
  39. Conclusions
  40. App A. rc.sysinit listing
  41. App B. functions listing
  42. App C. rc listing
  43. Credits

Linux Random Initialization

The random startup script


# 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.

# Source function library.
. /etc/rc.d/init.d/functions

random_seed=/var/run/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
		echo "The random data source exists"
	else
		echo "The random data source is missing"
	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
	echo "Usage: random {start|stop|status|restart|reload}"
	exit 1
esac

exit 0