From 06c0f3c55064376e81bbdba3b5dddc3d3bdf64c7 Mon Sep 17 00:00:00 2001 From: th33xitus Date: Fri, 3 Feb 2023 18:56:56 +0100 Subject: [PATCH 1/5] refactor: re-arrange/ clean up menus Signed-off-by: Dominik Willner --- scripts/ui/install_menu.sh | 9 --------- scripts/ui/main_menu.sh | 2 +- scripts/ui/remove_menu.sh | 11 ++++------- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/scripts/ui/install_menu.sh b/scripts/ui/install_menu.sh index 8ac01c0..c17942f 100755 --- a/scripts/ui/install_menu.sh +++ b/scripts/ui/install_menu.sh @@ -29,10 +29,6 @@ function install_ui() { echo -e "| | |" echo -e "| Touchscreen GUI: | Webcam Streamer: |" echo -e "| 5) [KlipperScreen] | 10) [Crowsnest] |" -# echo -e "| Touchscreen GUI: | |" -# echo -e "| 5) [KlipperScreen] | |" -# echo -e "| Touchscreen GUI: | Webcam Streamer: |" -# echo -e "| 5) [KlipperScreen] | 10) [MJPG-Streamer] |" back_footer } @@ -70,11 +66,6 @@ function install_menu() { do_action "moonraker_obico_setup_dialog" "install_ui";; 10) do_action "install_crowsnest" "install_ui";; -# 10) -# do_action "install_mjpg-streamer" "install_ui";; -# clear && print_header -# print_error "Function currently disabled! Sorry!" -# install_ui;; B|b) clear; main_menu; break;; *) diff --git a/scripts/ui/main_menu.sh b/scripts/ui/main_menu.sh index ad9c14f..42e9a06 100755 --- a/scripts/ui/main_menu.sh +++ b/scripts/ui/main_menu.sh @@ -29,8 +29,8 @@ function main_ui() { echo -e "| | Fluidd: $(print_status "fluidd")|" echo -e "| | KlipperScreen: $(print_status "klipperscreen")|" echo -e "| 6) [Settings] | Telegram Bot: $(print_status "telegram_bot")|" - echo -e "| | Obico: $(print_status "moonraker_obico")|" echo -e "| | Crowsnest: $(print_status "crowsnest")|" + echo -e "| | Obico: $(print_status "moonraker_obico")|" echo -e "| | |" echo -e "| $(print_kiauh_version)| Octoprint: $(print_status "octoprint")|" quit_footer diff --git a/scripts/ui/remove_menu.sh b/scripts/ui/remove_menu.sh index a1aed4d..2cae157 100755 --- a/scripts/ui/remove_menu.sh +++ b/scripts/ui/remove_menu.sh @@ -21,10 +21,9 @@ function remove_ui() { echo -e "| 1) [Klipper] | 6) [OctoPrint] |" echo -e "| 2) [Moonraker] | |" echo -e "| | Webcam Streamer: |" - echo -e "| Klipper Webinterface: | 7) [MJPG-Streamer] |" - echo -e "| 3) [Mainsail] | 12) [Crowsnest] |" - echo -e "| 4) [Fluidd] | |" - echo -e "| | Other: |" + echo -e "| Klipper Webinterface: | 7) [Crowsnest] |" + echo -e "| 3) [Mainsail] | |" + echo -e "| 4) [Fluidd] | Other: |" echo -e "| | 8) [PrettyGCode] |" echo -e "| Touchscreen GUI: | 9) [Telegram Bot] |" echo -e "| 5) [KlipperScreen] | 10) [Obico for Klipper] |" @@ -52,7 +51,7 @@ function remove_menu() { 6) do_action "remove_octoprint" "remove_ui";; 7) - do_action "remove_mjpg-streamer" "remove_ui";; + do_action "remove_crowsnest" "remove_ui";; 8) do_action "remove_prettygcode" "remove_ui";; 9) @@ -61,8 +60,6 @@ function remove_menu() { do_action "remove_moonraker_obico" "remove_ui";; 11) do_action "remove_nginx" "remove_ui";; - 12) - do_action "remove_crowsnest" "remove_ui";; B|b) clear; main_menu; break;; *) From 1221220f7d7ed568aa6b14cc8635541f89906394 Mon Sep 17 00:00:00 2001 From: th33xitus Date: Fri, 3 Feb 2023 19:15:16 +0100 Subject: [PATCH 2/5] chore: some reformatting Signed-off-by: Dominik Willner --- scripts/crowsnest.sh | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/scripts/crowsnest.sh b/scripts/crowsnest.sh index f31c13d..b8f6ef8 100644 --- a/scripts/crowsnest.sh +++ b/scripts/crowsnest.sh @@ -70,16 +70,15 @@ function continue_config() { while true; do read -erp "${cyan}###### Continuing with configuration? (y/N):${white} " reply case "${reply}" in - [Yy]* ) - break - ;; - [Nn]* ) + Y|y|Yes|yes) + select_msg "Yes" + break;; + N|n|No|no|"") + select_msg "No" warn_msg "Installation aborted by user ... Exiting!" - exit 1 - ;; - * ) - echo -e "\e[31mERROR: Please type Y or N !\e[0m" - ;; + exit 1;; + *) + error_msg "Invalid Input!\n";; esac done return 0 @@ -93,16 +92,13 @@ function install_crowsnest(){ # Step 2: Clone crowsnest repo status_msg "Cloning 'crowsnest' repository ..." - if [[ ! -d "${HOME}/crowsnest" ]] && - [[ -z "$(ls -A "${HOME}/crowsnest")" ]]; then + if [[ ! -d "${HOME}/crowsnest" && -z "$(ls -A "${HOME}/crowsnest")" ]]; then clone_crowsnest else ok_msg "crowsnest repository already exists ..." fi # Step 3: Install dependencies - # status_msg "Install basic dependencies ..." - # install_basic_deps dependency_check git make # Step 4: Check for Multi Instance @@ -159,7 +155,7 @@ get_crowsnest_status(){ echo "Installed" elif [[ "${count}" -gt 0 ]]; then echo "Incomplete!" - else + else echo "Not installed!" fi } From d5e202a18eca5863e3d134c81f95513cbf5e9a20 Mon Sep 17 00:00:00 2001 From: th33xitus Date: Fri, 3 Feb 2023 19:21:35 +0100 Subject: [PATCH 3/5] chore: cleanup variable braces are enabled by global role, other rule seems to be not required? Signed-off-by: Dominik Willner --- scripts/crowsnest.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/crowsnest.sh b/scripts/crowsnest.sh index b8f6ef8..f0547d8 100644 --- a/scripts/crowsnest.sh +++ b/scripts/crowsnest.sh @@ -15,9 +15,6 @@ # https://github.com/KwadFan/crowsnest # #=======================================================================# -# shellcheck enable=require-variable-braces -# shellcheck disable=SC2154 - # Error Handling set -e From 518f31f6589ec06872b1b1245d12cb1495fb49d3 Mon Sep 17 00:00:00 2001 From: th33xitus Date: Fri, 3 Feb 2023 19:42:26 +0100 Subject: [PATCH 4/5] chore: fix some typos and pipe error to null Signed-off-by: Dominik Willner --- scripts/crowsnest.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scripts/crowsnest.sh b/scripts/crowsnest.sh index f0547d8..b76957e 100644 --- a/scripts/crowsnest.sh +++ b/scripts/crowsnest.sh @@ -21,9 +21,9 @@ set -e # Helper messages function multi_instance_message(){ - echo -e "Crowsnest is NOT designed to support Multi Instances." + echo -e "Crowsnest is NOT designed to support multi instances." echo -e "A Workaround for this is to choose the most used instance as a 'master'" - echo -e "Use this instance to setup your 'crowsnest.conf' and steering it's service.\n" + echo -e "Use this instance to set up your 'crowsnest.conf' and steering it's service.\n" echo -e "Found the following instances:\n" for i in ${1}; do select_msg "${i}" @@ -41,7 +41,7 @@ function check_multi_instance(){ local -a instances readarray -t instances < <(find "${HOME}" -regex "${HOME}/[a-zA-Z0-9_]+_data/*" -printf "%P\n" 2> /dev/null | sort) if [[ "${#instances[@]}" -gt 1 ]]; then - status_msg "Multi Instance Install detected ..." + status_msg "Multi instance install detected ..." multi_instance_message "${instances[*]}" if [[ -d "${HOME}/crowsnest" ]]; then pushd "${HOME}/crowsnest" &> /dev/null || exit 1 @@ -65,7 +65,7 @@ function check_multi_instance(){ function continue_config() { local reply while true; do - read -erp "${cyan}###### Continuing with configuration? (y/N):${white} " reply + read -erp "${cyan}###### Continue with configuration? (y/N):${white} " reply case "${reply}" in Y|y|Yes|yes) select_msg "Yes" @@ -89,7 +89,7 @@ function install_crowsnest(){ # Step 2: Clone crowsnest repo status_msg "Cloning 'crowsnest' repository ..." - if [[ ! -d "${HOME}/crowsnest" && -z "$(ls -A "${HOME}/crowsnest")" ]]; then + if [[ ! -d "${HOME}/crowsnest" && -z "$(ls -A "${HOME}/crowsnest" 2> /dev/null)" ]]; then clone_crowsnest else ok_msg "crowsnest repository already exists ..." @@ -119,14 +119,15 @@ function install_crowsnest(){ function remove_crowsnest(){ pushd "${HOME}/crowsnest" &> /dev/null || exit 1 title_msg "Uninstaller will prompt you for sudo password!" - status_msg "Launching crowsnest Uninstaller ..." + status_msg "Launching crowsnest uninstaller ..." if ! make uninstall; then error_msg "Something went wrong! Please try again..." exit 1 fi if [[ -e "${CROWSNEST_DIR}" ]]; then - status_msg "Removing Crowsnest directory ..." + status_msg "Removing crowsnest directory ..." rm -rf "${CROWSNEST_DIR}" + ok_msg "Directory removed!" fi } From e2a4bee5dc4e99c0a9ece0c77a8af67a3695b149 Mon Sep 17 00:00:00 2001 From: th33xitus Date: Fri, 3 Feb 2023 19:54:29 +0100 Subject: [PATCH 5/5] chore: fix one leftover typo Signed-off-by: Dominik Willner --- scripts/crowsnest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/crowsnest.sh b/scripts/crowsnest.sh index b76957e..523de3f 100644 --- a/scripts/crowsnest.sh +++ b/scripts/crowsnest.sh @@ -22,7 +22,7 @@ set -e function multi_instance_message(){ echo -e "Crowsnest is NOT designed to support multi instances." - echo -e "A Workaround for this is to choose the most used instance as a 'master'" + echo -e "A workaround for this is to choose the most used instance as a 'master'" echo -e "Use this instance to set up your 'crowsnest.conf' and steering it's service.\n" echo -e "Found the following instances:\n" for i in ${1}; do