3 # $FreeBSD: src/etc/rc.d/random,v 1.3 2003/04/18 17:55:05 mtm Exp $
4 # $DragonFly: src/etc/rc.d/random,v 1.3 2005/11/19 21:47:32 swildner Exp $
8 # REQUIRE: diskless mountcritlocal initrandom
15 start_cmd="random_start"
16 stop_cmd="random_stop"
20 if [ -f "${1}" -a -r "${1}" -a -s "${1}" ]; then
21 cat "${1}" | dd of=/dev/random bs=8k 2>/dev/null
27 # Reseed /dev/random with previously stored entropy.
28 case ${entropy_dir} in
32 entropy_dir=${entropy_dir:-/var/db/entropy}
33 if [ -d "${entropy_dir}" ]; then
34 if [ -w /dev/random ]; then
35 for seedfile in ${entropy_dir}/*; do
36 feed_dev_random "${seedfile}"
43 case ${entropy_file} in
47 if [ -w /dev/random ]; then
48 feed_dev_random "${entropy_file}"
56 # Write some entropy so when the machine reebots /dev/random
59 case ${entropy_file} in
63 echo -n 'Writing entropy file:'
67 if touch ${entropy_file}; then
68 entropy_file_confirmed="${entropy_file}"
70 # Try this as a reasonable alternative for read-only
71 # roots, diskless workstations, etc.
73 if touch /var/db/entropy; then
74 entropy_file_confirmed=/var/db/entropy
77 case ${entropy_file_confirmed} in
79 err 1 '${entropy_file_confirmed}:' \
80 ' entropy file write failed.'
83 dd if=/dev/random of=${entropy_file_confirmed} \
84 bs=4096 count=1 2> /dev/null