#!/usr/bin/env bash
apt install -y rng-tools haveged

#/etc/default/rng-tools

# Set to the input source for random data, leave undefined
# for the initscript to attempt auto-detection.  Set to /dev/null
# for the viapadlock driver.
#HRNGDEVICE=/dev/hwrng
#HRNGDEVICE=/dev/null

sed -i 's|^#HRNGDEVICE=/dev/null|&\nHRNGDEVICE=/dev/urandom|' /etc/default/rng-tool

# Additional options to send to rngd. See the rngd(8) manpage for
# more information.  Do not specify -r/--rng-device here, use
# HRNGDEVICE for that instead.
#RNGDOPTIONS="--hrng=intelfwh --fill-watermark=90% --feed-interval=1"
#RNGDOPTIONS="--hrng=viakernel --fill-watermark=90% --feed-interval=1"
#RNGDOPTIONS="--hrng=viapadlock --fill-watermark=90% --feed-interval=1"

sed -i '/viakernel/s/^#//g' /etc/default/rng-tool

#/etc/default/haveged

# Options to pass to haveged:
#   -w sets low entropy watermark (in bits)
#DAEMON_ARGS="-w 1024"
