From a8468de2d64218fff071a050826f0eeb127c7390 Mon Sep 17 00:00:00 2001 From: suvanbanerjee Date: Fri, 26 Apr 2024 16:43:26 +0530 Subject: [PATCH 1/3] fixed installer allowing unknown options --- utils/scenario.sh | 80 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 65 insertions(+), 15 deletions(-) diff --git a/utils/scenario.sh b/utils/scenario.sh index 4756a70..62c085b 100644 --- a/utils/scenario.sh +++ b/utils/scenario.sh @@ -40,23 +40,55 @@ if [ -f "$SCENARIO_PATH" ]; then if in_array SCENARIO_ALLOWED_OPTIONS "$option"; then case "$option" in uninstall) - [ "${options[$option]}" == "true" ] && CONFIRM_UNINSTALL="true" || CONFIRM_UNINSTALL="false" - export CONFIRM_UNINSTALL + if [[ "${options[$option]}" == "true" ]]; then + UNINSTALL="true" + else + UNINSTALL="false" + fi ;; method) - [ "${options[$option]}" == "containers" ] && METHOD="containers" || METHOD="virtualenv" - export METHOD + if [[ "${options[$option]}" == "containers" ]]; then + METHOD="containers" + elif [[ "${options[$option]}" == "virtualenv" ]]; then + METHOD="virtualenv" + else + export SCENARIO_NOT_SUPPORTED="true" + break + fi ;; channel) - [ "${options[$option]}" == "development" ] && CHANNEL="development" || CHANNEL="stable" - export CHANNEL + if [[ "${options[$option]}" == "development" ]]; then + CHANNEL="development" + elif [[ "${options[$option]}" == "stable" ]]; then + CHANNEL="stable" + else + export SCENARIO_NOT_SUPPORTED="true" + break + fi ;; profile) - [ -n "${options[$option]}" ] && export PROFILE="${options[$option]}" + if [[ "${options[$option]}" == "ovos" ]]; then + PROFILE="ovos" + elif [[ "${options[$option]}" == "satellite" ]]; then + PROFILE="satellite" + elif [[ "${options[$option]}" == "listener" ]]; then + PROFILE="listener" + elif [[ "${options[$option]}" == "server" ]]; then + PROFILE="server" + else + export SCENARIO_NOT_SUPPORTED="true" + break + fi ;; rapsberry_pi_tuning) - [ "${options[$option]}" == "true" ] && TUNING="yes" || TUNING="no" - export TUNING + if [[ "${options[$option]}" == "true" ]]; then + TUNING="yes" + elif [[ "${options[$option]}" == "false" ]]; then + TUNING="no" + else + export SCENARIO_NOT_SUPPORTED="true" + break + fi ;; features) for feature in "${!features[@]}"; do @@ -64,12 +96,24 @@ if [ -f "$SCENARIO_PATH" ]; then if in_array SCENARIO_ALLOWED_FEATURES "$feature"; then case "$feature" in skills) - [ "${features[$feature]}" == "true" ] && FEATURE_SKILLS="true" || FEATURE_SKILLS="false" - export FEATURE_SKILLS + if [[ "${features[$feature]}" == "true" ]]; then + FEATURE_SKILLS="true" + elif [[ "${features[$feature]}" == "false" ]]; then + FEATURE_SKILLS="false" + else + export SCENARIO_NOT_SUPPORTED="true" + break + fi ;; gui) - [ "${features[$feature]}" == "true" ] && FEATURE_GUI="true" || FEATURE_GUI="false" - export FEATURE_GUI + if [[ "${features[$feature]}" == "true" ]]; then + FEATURE_GUI="true" + elif [[ "${features[$feature]}" == "false" ]]; then + FEATURE_GUI="false" + else + export SCENARIO_NOT_SUPPORTED="true" + break + fi ;; *) export SCENARIO_NOT_SUPPORTED="true" @@ -103,8 +147,14 @@ if [ -f "$SCENARIO_PATH" ]; then done ;; share_telemetry) - [ "${options[$option]}" == "true" ] && SHARE_TELEMETRY="true" || SHARE_TELEMETRY="false" - export SHARE_TELEMETRY + if [[ "${options[$option]}" == "true" ]]; then + SHARE_TELEMETRY="true" + elif [[ "${options[$option]}" == "false" ]]; then + SHARE_TELEMETRY="false" + else + export SCENARIO_NOT_SUPPORTED="true" + break + fi ;; *) export SCENARIO_NOT_SUPPORTED="true" From 1e86b9d5c977bb42afc9b423afa9bd5bee5c8459 Mon Sep 17 00:00:00 2001 From: suvanbanerjee Date: Fri, 26 Apr 2024 16:45:02 +0530 Subject: [PATCH 2/3] Fix scenario.sh tuninstall option --- utils/scenario.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils/scenario.sh b/utils/scenario.sh index 62c085b..9c00e5c 100644 --- a/utils/scenario.sh +++ b/utils/scenario.sh @@ -42,8 +42,11 @@ if [ -f "$SCENARIO_PATH" ]; then uninstall) if [[ "${options[$option]}" == "true" ]]; then UNINSTALL="true" - else + elif [[ "${options[$option]}" == "false" ]]; then UNINSTALL="false" + else + export SCENARIO_NOT_SUPPORTED="true" + break fi ;; method) From d2a74d85454e83b65e58c9aec5a5c70b02be83d0 Mon Sep 17 00:00:00 2001 From: suvanbanerjee Date: Fri, 26 Apr 2024 17:44:17 +0530 Subject: [PATCH 3/3] Test BATS