Minimise the number of decisions during interactive install

This commit is contained in:
Bob Mottram 2015-11-30 14:25:09 +00:00
parent 79f5759a08
commit 3987268027
7 changed files with 359 additions and 288 deletions

Binary file not shown.

Binary file not shown.

View File

@ -53,6 +53,9 @@ INSTALLING_ON_BBB="no"
# Version number of this script
VERSION="1.01"
# if yes then this minimises the number of descisions presented during install
MINIMAL_INSTALL="yes"
# Different system variants which may be specified within
# the SYSTEM_TYPE option
VARIANT_FULL="full"
@ -473,6 +476,7 @@ function show_help {
echo ''
echo $' -h --help Show help'
echo $' menuconfig Easy interactive installation'
echo $' menuconfigfull Full interactive installation'
echo $' -c --config Installing from a configuration file'
echo $' --bbb Installing on Beaglebone Black'
echo $' -u --user User to install the system as'
@ -561,11 +565,20 @@ function interactive_configuration {
rm -f /tmp/meshuserdevice
fi
if [[ $MINIMAL_INSTALL == "no" ]]; then
freedombone-config \
-f $CONFIGURATION_FILE \
-w $FREEDOMBONE_WEBSITE \
-b $FREEDOMBONE_BITMESSAGE \
-m $MINIMUM_PASSWORD_LENGTH
else
freedombone-config \
-f $CONFIGURATION_FILE \
-w $FREEDOMBONE_WEBSITE \
-b $FREEDOMBONE_BITMESSAGE \
-m $MINIMUM_PASSWORD_LENGTH
--minimal "yes"
fi
if [ -f /tmp/meshuserdevice ]; then
# mesh network user device installation
rm -f /tmp/meshuserdevice
@ -574,7 +587,7 @@ function interactive_configuration {
if [ ! "$?" = "0" ]; then
echo 'Command failed:'
echo ''
echo " freedombone-config -u $MY_USERNAME -f $CONFIGURATION_FILE -w $FREEDOMBONE_WEBSITE -b $FREEDOMBONE_BITMESSAGE -m $MINIMUM_PASSWORD_LENGTH"
echo " freedombone-config -u $MY_USERNAME -f $CONFIGURATION_FILE -w $FREEDOMBONE_WEBSITE -b $FREEDOMBONE_BITMESSAGE -m $MINIMUM_PASSWORD_LENGTH --minimal [yes|no]"
echo ''
exit 73594
fi
@ -593,7 +606,14 @@ function interactive_configuration {
fi
}
if [[ $1 == "menuconfig" ]]; then
command_options=$1
if [[ $command_options == "menuconfigfull" ]]; then
MINIMAL_INSTALL="no"
command_options="menuconfig"
fi
if [[ $command_options == "menuconfig" ]]; then
interactive_configuration
else
while [[ $# > 1 ]]
@ -760,6 +780,11 @@ else
shift
DEBIAN_REPO=$1
;;
# minimal install
--minimal)
shift
MINIMAL_INSTALL=$1
;;
*)
# unknown option
;;
@ -830,7 +855,9 @@ function read_configuration {
if [[ $CONFIGURATION_FILE != '/root/freedombone.cfg' ]]; then
cp $CONFIGURATION_FILE /root/freedombone.cfg
fi
if grep -q "MINIMAL_INSTALL" $CONFIGURATION_FILE; then
MINIMAL_INSTALL=$(grep "MINIMAL_INSTALL" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "LETSENCRYPT_SERVER" $CONFIGURATION_FILE; then
LETSENCRYPT_SERVER=$(grep "LETSENCRYPT_SERVER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi

View File

@ -70,7 +70,7 @@ DEFAULT_DOMAIN_NAME=
DEFAULT_DOMAIN_CODE=
MY_EMAIL_ADDRESS=
SYSTEM_TYPE=
INSTALLING_ON_BBB=
INSTALLING_ON_BBB="no"
DDNS_PROVIDER=
DDNS_USERNAME=
DDNS_PASSWORD=
@ -107,6 +107,7 @@ BATMAN_CELLID='any'
WIFI_CHANNEL=
CONFIGURATION_FILE=
DH_KEYLENGTH=
MINIMAL_INSTALL="no"
function show_help {
echo ''
@ -120,6 +121,7 @@ function show_help {
echo $' -m --min Minimum password length (characters)'
echo $' -w --www Freedombone web site'
echo $' -b --bm Freedombone support Bitmessage address'
echo $' --minimal [yes|no] For minimalistic "consumer grade" installs'
echo ''
exit 0
}
@ -153,6 +155,10 @@ do
shift
FREEDOMBONE_BITMESSAGE="$1"
;;
--minimal)
shift
MINIMAL_INSTALL="$1"
;;
*)
# unknown option
;;
@ -731,6 +737,7 @@ function interactive_configuration {
fi
save_configuration_file
if [[ $MINIMAL_INSTALL == "no" ]]; then
if [[ $(grep "INSTALLING_ON_BBB" temp.cfg | awk -F '=' '{print $2}') == "yes" ]]; then
dialog --title $"Install Target" \
--backtitle $"Freedombone Configuration" \
@ -756,7 +763,9 @@ function interactive_configuration {
DH_KEYLENGTH=1024
fi
save_configuration_file
fi
if [[ $MINIMAL_INSTALL == "no" ]]; then
if [[ $SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
interactive_gpg
@ -780,7 +789,12 @@ function interactive_configuration {
esac
save_configuration_file
fi
else
# enable for the minimal case
ENABLE_SOCIAL_KEY_MANAGEMENT="yes"
fi
if [[ $MINIMAL_INSTALL == "no" ]]; then
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
if [[ $INSTALLING_ON_BBB != "yes" ]]; then
@ -804,7 +818,9 @@ function interactive_configuration {
HWRNG_TYPE="beaglebone"
fi
save_configuration_file
fi
if [[ $MINIMAL_INSTALL == "no" ]]; then
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Configuration" \
@ -916,7 +932,11 @@ function interactive_configuration {
255) exit 1;;
esac
save_configuration_file
else
DEBIAN_REPO='ftp.de.debian.org'
fi
if [[ $MINIMAL_INSTALL == "no" ]]; then
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Configuration" \
@ -994,6 +1014,11 @@ function interactive_configuration {
255) exit 1;;
esac
save_configuration_file
else
# as defaults for a minimal install process these settings are debatable
NAMESERVER1='85.214.73.63'
NAMESERVER2='213.73.91.35'
fi
if [[ $SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
@ -1093,6 +1118,7 @@ function interactive_configuration {
save_configuration_file
fi
if [[ $MINIMAL_INSTALL == "no" ]]; then
SET_STATIC_IP="no"
dialog --title $"Static local IP address" \
--backtitle $"Freedombone Configuration" \
@ -1134,6 +1160,7 @@ function interactive_configuration {
ROUTER_IP_ADDRESS=$(cat $data | sed -n 2p)
save_configuration_file
fi
fi
if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_FULL" ]]; then
WIKI_DETAILS_COMPLETE=
@ -1453,7 +1480,7 @@ function interactive_configuration {
trap "rm -f $data" 0 1 2 5 15
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
dialog --backtitle $"Freedombone Configuration" \
--title $"Default Domain" \
--title $"Your main domain name" \
--form $"\nWhich domain name should your email/XMPP/IRC/VoIP be associated with?" 11 55 3 \
$"Domain:" 1 1 "$(grep 'DEFAULT_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 16 25 30 \
$"Code:" 2 1 "$(grep 'DEFAULT_DOMAIN_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 16 25 30 \

View File

@ -76,6 +76,9 @@ INTERACTIVE="no"
# Whether this is a generic image for mass redistribution on the interwebs
GENERIC_IMAGE="no"
# Whether to reduce the number of decisions during interactive install
MINIMAL_INSTALL="yes"
while [[ $# > 1 ]]
do
key="$1"
@ -145,6 +148,10 @@ case $key in
shift
GENERIC_IMAGE="$1"
;;
--minimal)
shift
MINIMAL_INSTALL="$1"
;;
*)
# unknown option
;;
@ -153,7 +160,7 @@ shift
done
if [[ $INTERACTIVE == "yes" || $INTERACTIVE == "y" || $INTERACTIVE == "Yes" ]]; then
freedombone-config
freedombone-config --minimal "$MINIMAL_INSTALL"
if [ -f freedombone.cfg ]; then
CONFIG_FILENAME=freedombone.cfg
DEFAULT_DOMAIN_NAME=$(cat $CONFIG_FILENAME | grep 'DEFAULT_DOMAIN_NAME' | awk -F '=' '{print $2}')
@ -207,7 +214,8 @@ make $IMAGE_TYPE \
CONFIG_FILENAME="$CONFIG_FILENAME" \
IMAGE_SIZE="$IMAGE_SIZE" \
SSH_PUBKEY="$SSH_PUBKEY" \
GENERIC_IMAGE="$GENERIC_IMAGE"
GENERIC_IMAGE="$GENERIC_IMAGE" \
MINIMAL_INSTALL="$MINIMAL_INSTALL"
if [ ! "$?" = "0" ]; then
echo $'Build failed'

View File

@ -34,6 +34,9 @@ PROJECT_NAME='freedombone'
export TEXTDOMAIN=${PROJECT_NAME}-image-customise
export TEXTDOMAINDIR="/usr/share/locale"
# Whether to minimise the number of decisions during interactive install
MINIMAL_INSTALL="yes"
MY_USERNAME='debian'
MY_PASSWORD='freedombone'
@ -255,7 +258,11 @@ EOF
echo -n " echo \"${MY_USERNAME}:" >> $rootdir/root/.bashrc
echo '$(printf `cat ~/login.txt`)"|chpasswd' >> $rootdir/root/.bashrc
if [[ $MINIMAL_INSTALL == "no" ]]; then
echo ' freedombone menuconfigfull' >> $rootdir/root/.bashrc
else
echo ' freedombone menuconfig' >> $rootdir/root/.bashrc
fi
echo ' if [ "$?" = "0" ]; then' >> $rootdir/root/.bashrc
echo ' if [ -f ~/freedombone-completed.txt ]; then' >> $rootdir/root/.bashrc
# Remove the initial setup files

View File

@ -51,6 +51,7 @@ export PROJECT_NAME
export CONFIG_FILENAME
export SSH_PUBKEY
export GENERIC_IMAGE
export MINIMAL_INSTALL
# Locate vmdebootstrap program fetched in Makefile
basedir=`pwd`
@ -162,6 +163,7 @@ sudo sed -i "s|PROJECT_NAME=.*|PROJECT_NAME=${PROJECT_NAME}|g" $TEMP_CUSTOMISE
sudo sed -i "s|CONFIG_FILENAME=.*|CONFIG_FILENAME=${CONFIG_FILENAME}|g" $TEMP_CUSTOMISE
sudo sed -i "s|SSH_PUBKEY=.*|SSH_PUBKEY=${SSH_PUBKEY}|g" $TEMP_CUSTOMISE
sudo sed -i "s|GENERIC_IMAGE=.*|GENERIC_IMAGE=${GENERIC_IMAGE}|g" $TEMP_CUSTOMISE
sudo sed -i "s|MINIMAL_INSTALL=.*|MINIMAL_INSTALL=\"${MINIMAL_INSTALL}\"|g" $TEMP_CUSTOMISE
echo $"starting $VMDEBOOTSTRAP"
# Run vmdebootstrap script to create image