#!/sbin/runscript
# Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /home/cvsroot/gentoo-src/rc-scripts/init.d/urandom,v 1.6 2002/11/18 13:07:02 azarah Exp $


depend() {
	need localmount
}

start() {
	[ -c /dev/urandom ] || return
	ebegin "Initializing random number generator"
	if [ -f /var/run/random-seed ]
	then
	    cat /var/run/random-seed >/dev/urandom
	fi
	rm -f /var/run/random-seed &>/dev/null
	umask 077
	dd if=/dev/urandom of=/var/run/random-seed count=1 &>/dev/null
	eend $? "Error initializing random number generator"
	umask 022
}

stop() {
	ebegin "Saving random seed"
	# Carry a random seed from shut-down to start-up;
	# see documentation in linux/drivers/char/random.c
	umask 077
	dd if=/dev/urandom of=/var/run/random-seed count=1 &>/dev/null
	eend $? "Failed to save random seed."
}


# vim:ts=4
