#!/bin/sh
#
# Copyright (C) 2018 SpinetiX
#

# Seeds the random source with secure material when there is no saved
# entropy available. This is to ensure that a freshly installed system
# can generate secure random numbers before being able to gather
# entropy from system events.
#
# It MUST run before the urandom boot script.

test -c /dev/urandom || exit 0

case "$1" in
    start)
    	if ! [ -f /var/lib/urandom/random-seed ] ; then
    	    echo "seeding urandom"
    	    spxentropy -l 512 -o /dev/urandom
    	fi
    	;;
    *)
    	echo "Usage spxentropy start" >&2
    	exit 1
    	;;
esac

exit 0