#!/bin/sh
########################################################################
# Begin $rc_base/init.d/rngd
#
# Description : Random Number Generator Daemon
#
# Authors     : Michael Tremer <michael.tremer@ipfire.org>
#
########################################################################

. /etc/sysconfig/rc
. ${rc_functions}

case "${1}" in
	start)
		if pidofproc -s /usr/sbin/rngd; then
			boot_mesg "Random Number Generator Daemon is already running..."
			echo_ok;
			exit 0
		fi
		if [ -e /dev/hwrngtty ]; then
			HWRNG=/dev/hwrngtty
		else
			HWRNG=/dev/hwrng
		fi
		boot_mesg "Starting Random Number Generator Daemon..."
		loadproc /usr/sbin/rngd -r $HWRNG --quiet
		;;

	stop)
		boot_mesg "Stopping Random Number Generator Daemon..."
		killproc -p /var/run/rngd.pid /usr/sbin/rngd
		;;

	restart)
		${0} stop
		sleep 1
		${0} start
		;;

	status)
		statusproc /usr/sbin/rngd
		;;

	udev-event)
		$0 restart &>/dev/null
		;;

	*)
		echo "Usage: ${0} {start|stop|restart|status}"
		exit 1
		;;
esac

# End $rc_base/init.d/rngd
