NetBSD/etc/rc.d/entropy

41 lines
858 B
Bash

#!/bin/sh
#
# $NetBSD: entropy,v 1.1 2021/01/10 23:24:25 riastradh Exp $
#
# PROVIDE: entropy
# REQUIRE: random_seed rndctl
# BEFORE: ike ipsec network
$_rc_subr_loaded . /etc/rc.subr
name="entropy"
start_cmd="entropy_start"
stop_cmd=":"
entropy_start()
{
case ${entropy-} in
'') ;;
check) echo -n "Checking for entropy..."
# dd will print an error message `Resource temporarily
# unavailable' to stderr, which is a little annoying,
# but getting rid of it is also a little annoying.
if dd if=/dev/random iflag=nonblock of=/dev/null bs=1 count=1 \
msgfmt=quiet; then
echo "done"
else
echo "not enough entropy available, aborting boot."
stop_boot
fi
;;
wait) echo -n "Waiting for entropy..."
dd if=/dev/random of=/dev/null bs=1 count=1 msgfmt=quiet
echo "done"
;;
esac
}
load_rc_config "$name"
run_rc_command "$1"