From 0b36287289b387a661aa285151a8505e5bd2e8b6 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 13 Jun 2015 12:00:11 +0100 Subject: [PATCH] Select HRNG type, rather than just yes or no --- src/freedombone | 26 +++++++++++++++++++++----- src/freedombone-config | 22 ++++++++++++++++++++++ 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/freedombone b/src/freedombone index 7754858a..f95603db 100755 --- a/src/freedombone +++ b/src/freedombone @@ -106,8 +106,9 @@ TLS_TIME_SOURCE2="www.ptb.de" # See http://rcn-ee.net/deb/jessie-armhf/ KERNEL_VERSION="v3.15.10-bone8" -# Whether or not to use the beaglebone's hardware random number generator -USE_HWRNG="yes" +# The type of hardware random number generator being used +# This can be empty, "beaglebone" or "onerng" +HWRNG_TYPE= # Whether this system is being installed within a docker container INSTALLED_WITHIN_DOCKER="no" @@ -694,6 +695,9 @@ function read_configuration { fi if [ -f $CONFIGURATION_FILE ]; then + if grep -q "HWRNG_TYPE" $CONFIGURATION_FILE; then + HWRNG_TYPE=$(grep "HWRNG_TYPE" $CONFIGURATION_FILE | awk -F '=' '{print $2}') + fi if grep -q "MEDIAGOBLIN_DOMAIN_NAME" $CONFIGURATION_FILE; then MEDIAGOBLIN_DOMAIN_NAME=$(grep "MEDIAGOBLIN_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}') fi @@ -4726,6 +4730,10 @@ function enable_zram { echo 'enable_zram' >> $COMPLETION_FILE } +function install_onerng { + # TODO +} + function random_number_generator { if grep -Fxq "random_number_generator" $COMPLETION_FILE; then return @@ -4742,12 +4750,20 @@ function random_number_generator { # generator of the host system return fi - if [[ $USE_HWRNG == "yes" ]]; then + + case $HWRNG_TYPE in + beaglebone) apt-get -y install rng-tools sed -i 's|#HRNGDEVICE=/dev/hwrng|HRNGDEVICE=/dev/hwrng|g' /etc/default/rng-tools - else + ;; + onerng) + install_onerng + ;; + *) apt-get -y install haveged - fi + ;; + esac + echo 'random_number_generator' >> $COMPLETION_FILE } diff --git a/src/freedombone-config b/src/freedombone-config index a0887b83..6c862628 100755 --- a/src/freedombone-config +++ b/src/freedombone-config @@ -85,6 +85,7 @@ GIT_CODE= MEDIAGOBLIN_DOMAIN_NAME= MEDIAGOBLIN_CODE= USB_DRIVE=/dev/sdb1 +HWRNG_TYPE= CONFIGURATION_FILE= @@ -214,6 +215,9 @@ function save_configuration_file { if [ $MEDIAGOBLIN_CODE ]; then echo "MEDIAGOBLIN_CODE=$MEDIAGOBLIN_CODE" >> $CONFIGURATION_FILE fi + if [ $HWRNG_TYPE ]; then + echo "HWRNG=$HWRNG" >> $CONFIGURATION_FILE + fi } # test a domain name to see if it's valid @@ -321,6 +325,24 @@ function interactive_configuration { fi save_configuration_file + data=$(tempfile 2>/dev/null) + trap "rm -f $data" 0 1 2 5 15 + dialog --backtitle "Random Number Generation" \ + --radiolist "Type of RNG:" 17 40 3 \ + 1 Haveged on \ + 2 Beaglebone built-in HRNG off \ + 3 OneRNG off 2> $data + sel=$? + case $sel in + 1) exit 0;; + 255) exit 0;; + esac + case $(cat $data) in + 2) HWRNG_TYPE="beaglebone";; + 3) HWRNG_TYPE="onerng";; + esac + save_configuration_file + data=$(tempfile 2>/dev/null) trap "rm -f $data" 0 1 2 5 15 dialog --backtitle "Freedombone Configuration" \