From 54fcc1f3f6aadcbd8833aea6b88fb812c0d0d44a Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 31 Jan 2016 13:31:40 +0000 Subject: [PATCH] Include trove selection in interactive install --- src/freedombone-config | 71 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/src/freedombone-config b/src/freedombone-config index a01b2889..6cc4b6cb 100755 --- a/src/freedombone-config +++ b/src/freedombone-config @@ -111,6 +111,12 @@ MINIMAL_INSTALL="yes" DEFAULT_LANGUAGE='en_GB.UTF-8' ONION_ONLY="no" +# Trove settings +FRIENDS_TROVE_SERVER= +FRIENDS_TROVE_SSH_PORT=2222 +FRIENDS_TROVE_PASSWORD= +MY_TROVE_PASSWORD= + function show_help { echo '' echo $"${PROJECT_NAME}-config -f [config filename] -m [min password length]" @@ -281,6 +287,16 @@ function save_configuration_file { echo "DH_KEYLENGTH=$DH_KEYLENGTH" >> $CONFIGURATION_FILE fi echo "ONION_ONLY=$ONION_ONLY" >> $CONFIGURATION_FILE + + if [ $FRIENDS_TROVE_SERVER ]; then + echo "FRIENDS_TROVE_SERVER=$FRIENDS_TROVE_SERVER" >> $CONFIGURATION_FILE + fi + if [ $FRIENDS_TROVE_SSH_PORT ]; then + echo "FRIENDS_TROVE_SSH_PORT=$FRIENDS_TROVE_SSH_PORT" >> $CONFIGURATION_FILE + fi + if [ $FRIENDS_TROVE_PASSWORD ]; then + echo "FRIENDS_TROVE_PASSWORD=$FRIENDS_TROVE_PASSWORD" >> $CONFIGURATION_FILE + fi } # test a domain name to see if it's valid @@ -512,6 +528,47 @@ function interactive_gpg { done } +function set_main_repo { + data=$(tempfile 2>/dev/null) + trap "rm -f $data" 0 1 2 5 15 + dialog --backtitle $"Freedombone Control Panel" \ + --title $"Main Repository (Trove)" \ + --form $"If you do not wish to use the default repositories they can be obtained from another ${PROJECT_NAME} server acting as a trove.\n\nA trove is a mirrored collection of git repositories for systems which are not yet packaged for Debian.\n\nTo use the defaults just select Ok." 18 65 4 \ + $"URL:" 1 1 "$FRIENDS_TROVE_SERVER" 1 18 40 18 \ + $"SSH Port:" 2 1 "$FRIENDS_TROVE_SSH_PORT" 2 18 10 10000 \ + $"Password:" 3 1 "$FRIENDS_TROVE_PASSWORD" 3 18 40 10000 \ + 2> $data + sel=$? + case $sel in + 1) return;; + 255) return;; + esac + new_trove_url=$(cat $data | sed -n 1p) + new_trove_ssh_port=$(cat $data | sed -n 2p) + new_trove_password=$(cat $data | sed -n 3p) + + if [ ${#new_trove_url} -lt 2 ]; then + return + fi + if [ ${#new_trove_ssh_port} -lt 1 ]; then + return + fi + if [ ${#new_trove_password} -lt 10 ]; then + dialog --title $"Main Repository" \ + --msgbox $'Trove password was too short. Should be at least 10 characters.' 6 40 + return + fi + + if [[ $new_trove_url == *"."* ]]; then + FRIENDS_TROVE_SERVER=$new_trove_url + FRIENDS_TROVE_SSH_PORT=$new_trove_ssh_port + FRIENDS_TROVE_PASSWORD=$new_trove_password + + dialog --title $"Main Repository" \ + --msgbox $"Main repository set to $FRIENDS_TROVE_SERVER" 6 60 + fi +} + function interactive_select_language { data=$(tempfile 2>/dev/null) trap "rm -f $data" 0 1 2 5 15 @@ -595,6 +652,11 @@ function interactive_configuration { esac save_configuration_file + if [[ $SYSTEM_TYPE != "$VARIANT_MESH" && $SYSTEM_TYPE != "$VARIANT_MESH_USER" ]]; then + set_main_repo + save_configuration_file + fi + if [[ $SYSTEM_TYPE == "$VARIANT_MESH" || $SYSTEM_TYPE == "$VARIANT_MESH_USER" ]]; then ENABLE_BATMAN="yes" ENABLE_CJDNS="no" @@ -1692,6 +1754,15 @@ function read_configuration { fi if [ -f $CONFIGURATION_FILE ]; then + if grep -q "FRIENDS_TROVE_SERVER" $CONFIGURATION_FILE; then + FRIENDS_TROVE_SERVER=$(grep "FRIENDS_TROVE_SERVER" $CONFIGURATION_FILE | awk -F '=' '{print $2}') + fi + if grep -q "FRIENDS_TROVE_SSH_PORT" $CONFIGURATION_FILE; then + FRIENDS_TROVE_SSH_PORT=$(grep "FRIENDS_TROVE_SSH_PORT" $CONFIGURATION_FILE | awk -F '=' '{print $2}') + fi + if grep -q "FRIENDS_TROVE_PASSWORD" $CONFIGURATION_FILE; then + FRIENDS_TROVE_PASSWORD=$(grep "FRIENDS_TROVE_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}') + fi if grep -q "ENABLE_SOCIAL_KEY_MANAGEMENT" $CONFIGURATION_FILE; then ENABLE_SOCIAL_KEY_MANAGEMENT=$(grep "ENABLE_SOCIAL_KEY_MANAGEMENT" $CONFIGURATION_FILE | awk -F '=' '{print $2}') fi