summaryrefslogtreecommitdiff
path: root/package/rng-tools/files/rngd.init
blob: 740c5ead7f4491fc450f8e06ec24ca481c4fc0e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh
#PKG rng-tools
#INIT 60
. /etc/rc.conf

case $1 in
autostop) ;;
autostart)
	test x"${rngd:-NO}" = x"NO" && exit 0
	test x"$rngd" = x"DAEMON" && test -x /bin/mksh && exec mksh -T- $0 start
	exec sh $0 start
	;;
start)
	devnode=""
	for node in hw_random hwrandom i810_rng hwrng; do
		if [ -e /dev/$node ]; then
			devnode=/dev/$node
			break
		fi
	done
	if [ -z "$devnode" ]; then
		echo "no hardware RNG found, falling back to /dev/urandom"
		devnode=/dev/urandom
	fi
	/usr/sbin/rngd -b -r $devnode
	;;
stop)
	kill $(pgrep -f /usr/sbin/rngd)
	;;
restart)
	sh $0 stop
	sleep 1
	sh $0 start
	;;
*)
	echo "Usage: $0 {start | stop | restart}"
	exit 1
	;;
esac
exit $?