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