Select HRNG type, rather than just yes or no

This commit is contained in:
Bob Mottram 2015-06-13 12:00:11 +01:00
parent 9418ba3990
commit 0b36287289
2 changed files with 43 additions and 5 deletions

View File

@ -106,8 +106,9 @@ TLS_TIME_SOURCE2="www.ptb.de"
# See http://rcn-ee.net/deb/jessie-armhf/ # See http://rcn-ee.net/deb/jessie-armhf/
KERNEL_VERSION="v3.15.10-bone8" KERNEL_VERSION="v3.15.10-bone8"
# Whether or not to use the beaglebone's hardware random number generator # The type of hardware random number generator being used
USE_HWRNG="yes" # This can be empty, "beaglebone" or "onerng"
HWRNG_TYPE=
# Whether this system is being installed within a docker container # Whether this system is being installed within a docker container
INSTALLED_WITHIN_DOCKER="no" INSTALLED_WITHIN_DOCKER="no"
@ -694,6 +695,9 @@ function read_configuration {
fi fi
if [ -f $CONFIGURATION_FILE ]; then 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 if grep -q "MEDIAGOBLIN_DOMAIN_NAME" $CONFIGURATION_FILE; then
MEDIAGOBLIN_DOMAIN_NAME=$(grep "MEDIAGOBLIN_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}') MEDIAGOBLIN_DOMAIN_NAME=$(grep "MEDIAGOBLIN_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi fi
@ -4726,6 +4730,10 @@ function enable_zram {
echo 'enable_zram' >> $COMPLETION_FILE echo 'enable_zram' >> $COMPLETION_FILE
} }
function install_onerng {
# TODO
}
function random_number_generator { function random_number_generator {
if grep -Fxq "random_number_generator" $COMPLETION_FILE; then if grep -Fxq "random_number_generator" $COMPLETION_FILE; then
return return
@ -4742,12 +4750,20 @@ function random_number_generator {
# generator of the host system # generator of the host system
return return
fi fi
if [[ $USE_HWRNG == "yes" ]]; then
case $HWRNG_TYPE in
beaglebone)
apt-get -y install rng-tools apt-get -y install rng-tools
sed -i 's|#HRNGDEVICE=/dev/hwrng|HRNGDEVICE=/dev/hwrng|g' /etc/default/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 apt-get -y install haveged
fi ;;
esac
echo 'random_number_generator' >> $COMPLETION_FILE echo 'random_number_generator' >> $COMPLETION_FILE
} }

View File

@ -85,6 +85,7 @@ GIT_CODE=
MEDIAGOBLIN_DOMAIN_NAME= MEDIAGOBLIN_DOMAIN_NAME=
MEDIAGOBLIN_CODE= MEDIAGOBLIN_CODE=
USB_DRIVE=/dev/sdb1 USB_DRIVE=/dev/sdb1
HWRNG_TYPE=
CONFIGURATION_FILE= CONFIGURATION_FILE=
@ -214,6 +215,9 @@ function save_configuration_file {
if [ $MEDIAGOBLIN_CODE ]; then if [ $MEDIAGOBLIN_CODE ]; then
echo "MEDIAGOBLIN_CODE=$MEDIAGOBLIN_CODE" >> $CONFIGURATION_FILE echo "MEDIAGOBLIN_CODE=$MEDIAGOBLIN_CODE" >> $CONFIGURATION_FILE
fi fi
if [ $HWRNG_TYPE ]; then
echo "HWRNG=$HWRNG" >> $CONFIGURATION_FILE
fi
} }
# test a domain name to see if it's valid # test a domain name to see if it's valid
@ -321,6 +325,24 @@ function interactive_configuration {
fi fi
save_configuration_file 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) data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15 trap "rm -f $data" 0 1 2 5 15
dialog --backtitle "Freedombone Configuration" \ dialog --backtitle "Freedombone Configuration" \