From c9f8427ecb804f5e5dd1fccc622c5b56fe84b8da Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 9 Oct 2016 22:17:33 +0100 Subject: [PATCH] Choosing a variant --- src/freedombone-config | 14 +++++++------- src/freedombone-utils-selector | 7 ++++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/freedombone-config b/src/freedombone-config index 15fa2726..72710f27 100755 --- a/src/freedombone-config +++ b/src/freedombone-config @@ -773,11 +773,10 @@ function choose_full_name { function choose_system_variant { available_variants_list=() - variants_list=$(available_system_variants) + available_system_variants varslist="" n=1 - vars_index=0 for a in "${available_variants_list[@]}" do varstate='off' @@ -786,17 +785,18 @@ function choose_system_variant { fi varslist="$varslist $n $a $varstate" n=$[n+1] - vars_index=$[vars_index+1] done variant_choice=$(dialog --stdout --backtitle $"Freedombone Configuration" \ --title $"Type of Installation" \ --radiolist $'Choose:' \ 27 40 20 $varslist) - variant_choice=$((variant_choice - 1)) - export SYSTEM_TYPE=${variants_list[$variant_choice]} - save_configuration_values - write_config_param "SYSTEM_TYPE" "$SYSTEM_TYPE" + + if [ $? -eq 0 ]; then + variant_choice=$[variant_choice-1] + SYSTEM_TYPE=${available_variants_list[$variant_choice]} + save_configuration_values + fi } function validate_freedns_code { diff --git a/src/freedombone-utils-selector b/src/freedombone-utils-selector index 1d9d51ff..e78228ed 100755 --- a/src/freedombone-utils-selector +++ b/src/freedombone-utils-selector @@ -99,19 +99,20 @@ function item_in_array { function available_system_variants { FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-* - available_variants_list=() + new_available_variants_list=() for filename in $FILES do system_variants_list=$(app_variants $filename) variants_array=($system_variants_list) for variant_str in "${variants_array[@]}" do - item_in_array "${variant_str}" "${available_variants_list[@]}" + item_in_array "${variant_str}" "${new_available_variants_list[@]}" if [[ $? != 0 ]]; then - available_variants_list+=("$variant_str") + new_available_variants_list+=("$variant_str") fi done done + available_variants_list=($(sort <<<"${new_available_variants_list[*]}")) } function is_valid_variant {