3 # random Script to snapshot random state and reload it at boot time.
5 # chkconfig: 12345 20 80
7 # description: Saves and restores system entropy pool for higher quality \
8 # random number generation.
11 # Source function library.
12 . /etc/rc.d/init.d/functions
14 random_seed=/var/run/random-seed
16 poolfile=/proc/sys/kernel/random/poolsize
17 [ -r $poolfile ] && bytes="$(cat $poolfile)" || bytes=512
20 # Check if the service is already running?
21 if [ -f /var/lock/subsys/random ]; then
25 show "Initializing random number generator"
27 # Carry a random seed from start-up to start-up
28 if [ -f $random_seed ]; then
29 cat $random_seed >/dev/urandom
33 chmod 600 $random_seed
34 dd if=/dev/urandom of=$random_seed count=1 bs=$bytes 2>/dev/null
35 touch /var/lock/subsys/random
41 if [ ! -f /var/lock/subsys/random ]; then
45 # Carry a random seed from shut-down to start-up
46 show "Saving random seed"
49 chmod 600 $random_seed
50 dd if=/dev/urandom of=$random_seed count=1 bs=$bytes 2>/dev/null
52 rm -f /var/lock/subsys/random >/dev/null 2>&1
58 entropy_avail="$(cat /proc/sys/kernel/random/entropy_avail)"
59 if [ "$entropy_avail" -eq 0 -o ! -c /dev/random ] ; then
60 nls "The random data source is missing"
63 nls "%d bytes of entropy available" $entropy_avail
67 # See how we were called.
79 msg_usage "$0 {start|stop|status}"