9 # KEYWORD: nojail shutdown
14 start_cmd="random_start"
15 stop_cmd="random_stop"
17 extra_commands="saveseed"
18 saveseed_cmd="${name}_stop"
24 debug "saving entropy to $f"
25 dd if=/dev/random of="$f" bs=4096 count=1 2>/dev/null
33 if [ -f "$f" -a -r "$f" -a -s "$f" ] ; then
34 if dd if="$f" of=/dev/random bs=4096 2>/dev/null ; then
35 debug "entropy read from $f"
44 echo -n 'Feeding entropy:'
46 if [ ! -w /dev/random ] ; then
47 warn "/dev/random is not writeable"
51 # Reseed /dev/random with previously stored entropy.
52 case ${entropy_dir:=/var/db/entropy} in
56 if [ -d "${entropy_dir}" ] ; then
57 feed_dev_random "${entropy_dir}"/*
62 case ${entropy_file:=/entropy} in
66 feed_dev_random "${entropy_file}" /var/db/entropy-file
67 save_dev_random "${entropy_file}"
76 # Write some entropy so when the machine reboots /dev/random
79 case ${entropy_file:=/entropy} in
83 echo -n 'Writing entropy file:'
84 rm -f ${entropy_file} 2> /dev/null
87 if touch ${entropy_file} 2> /dev/null; then
88 entropy_file_confirmed="${entropy_file}"
90 # Try this as a reasonable alternative for read-only
91 # roots, diskless workstations, etc.
92 rm -f /var/db/entropy-file 2> /dev/null
93 if touch /var/db/entropy-file 2> /dev/null; then
94 entropy_file_confirmed=/var/db/entropy-file
97 case ${entropy_file_confirmed} in
99 warn 'write failed (read-only fs?)'
102 dd if=/dev/random of=${entropy_file_confirmed} \
103 bs=4096 count=1 2> /dev/null