1 1.1 riastrad #!/bin/sh 2 1.1 riastrad # 3 1.1 riastrad # $NetBSD: entropy,v 1.1 2021/01/10 23:24:25 riastradh Exp $ 4 1.1 riastrad # 5 1.1 riastrad 6 1.1 riastrad # PROVIDE: entropy 7 1.1 riastrad # REQUIRE: random_seed rndctl 8 1.1 riastrad # BEFORE: ike ipsec network 9 1.1 riastrad 10 1.1 riastrad $_rc_subr_loaded . /etc/rc.subr 11 1.1 riastrad 12 1.1 riastrad name="entropy" 13 1.1 riastrad start_cmd="entropy_start" 14 1.1 riastrad stop_cmd=":" 15 1.1 riastrad 16 1.1 riastrad entropy_start() 17 1.1 riastrad { 18 1.1 riastrad case ${entropy-} in 19 1.1 riastrad '') ;; 20 1.1 riastrad check) echo -n "Checking for entropy..." 21 1.1 riastrad # dd will print an error message `Resource temporarily 22 1.1 riastrad # unavailable' to stderr, which is a little annoying, 23 1.1 riastrad # but getting rid of it is also a little annoying. 24 1.1 riastrad if dd if=/dev/random iflag=nonblock of=/dev/null bs=1 count=1 \ 25 1.1 riastrad msgfmt=quiet; then 26 1.1 riastrad echo "done" 27 1.1 riastrad else 28 1.1 riastrad echo "not enough entropy available, aborting boot." 29 1.1 riastrad stop_boot 30 1.1 riastrad fi 31 1.1 riastrad ;; 32 1.1 riastrad wait) echo -n "Waiting for entropy..." 33 1.1 riastrad dd if=/dev/random of=/dev/null bs=1 count=1 msgfmt=quiet 34 1.1 riastrad echo "done" 35 1.1 riastrad ;; 36 1.1 riastrad esac 37 1.1 riastrad } 38 1.1 riastrad 39 1.1 riastrad load_rc_config "$name" 40 1.1 riastrad run_rc_command "$1" 41