Unconstify members of the lconv structure to make it conform to the C89 and
[dragonfly/port-amd64.git] / etc / rc.d / initrandom
bloba5c44fe6a492e5e397aa154ca303cb89c53b7abb
1 #!/bin/sh
3 # $FreeBSD: src/etc/rc.d/initrandom,v 1.1 2002/06/13 22:14:36 gordon Exp $
4 # $DragonFly: src/etc/rc.d/initrandom,v 1.6 2006/07/10 22:19:14 dillon Exp $
7 # PROVIDE: initrandom
8 # REQUIRE: initdiskless
9 # BEFORE: disks
11 . /etc/rc.subr
13 name="initrandom"
14 start_cmd="initrandom_start"
15 stop_cmd=":"
17 feed_dev_random()
19 if [ -f "${1}" -a -r "${1}" -a -s "${1}" ]; then
20 sysctl kern.seedenable=1
21 cat "${1}" | dd of=/dev/random bs=8k 2>/dev/null
22 sysctl kern.seedenable=0
26 initrandom_start()
28 echo '.'
30 # First pass at reseeding /dev/random.
32 case ${entropy_file} in
33 [Nn][Oo] | '')
36 if [ -w /dev/random ]; then
37 feed_dev_random "${entropy_file}"
40 esac
42 # Mix in more junk. At the very least this will make seeding a
43 # bit more machine specific. The sysctl -a will also catch the
44 # TSC, 8254, and a few other things that tend to be somewhat more
45 # random (even from a CD boot) so it isn't all that bad.
47 sysctl kern.seedenable=1
48 ( ps -fauxww; sysctl -a; date; df -ib; dmesg; ps -fauxww; ) \
49 2>&1 | dd of=/dev/random bs=8k 2>/dev/null
50 cat /bin/ls | dd of=/dev/random bs=8k 2>/dev/null
51 sysctl kern.seedenable=0
54 load_rc_config random
55 run_rc_command "$1"