#!/bin/sh

. /usr/share/rng-tools-debian/init-system-common

check() {
	readoptions
	hrngselect
	if ! finddevice; then
		logger -t rng-tools-debian \
		    'not starting: no hardware RNG device found'
		exit 34
	fi
	if skipdevice; then
		logger -t rng-tools-debian \
		    'not starting: /dev/hwrng is used by the kernel automatically'
		exit 33
	fi
}

case $1 in
(check)
	check
	;;
(start)
	check
	exec /usr/sbin/rngd -f -r $HRNGDEVICE $RNGDOPTIONS
	;;
(*)
	logger -t rng-tools-debian \
	    'rngd-systemd-helper: unknown command'
	exit 10
	;;
esac
