diff --git a/scripts/mainsail.sh b/scripts/mainsail.sh index 8dd2130..2cfb5c3 100644 --- a/scripts/mainsail.sh +++ b/scripts/mainsail.sh @@ -216,26 +216,25 @@ function get_mainsail_ver(){ } function mainsail_status(){ - mcount=0 - mainsail_data=( - "${MAINSAIL_DIR}" - "${NGINX_SA}/mainsail" - "${NGINX_SE}/mainsail" - ) - #count+1 for each found data-item from array - for md in "${mainsail_data[@]}" - do - if [ -e "${md}" ]; then - mcount=$((mcount + 1)) - fi + local status + + ### remove the "SERVICE" entry from the data array if a moonraker service is installed + local data_arr=("${MAINSAIL_DIR}" "${NGINX_SA}/mainsail" "${NGINX_SE}/mainsail") + + ### count+1 for each found data-item from array + local filecount=0 + for data in "${data_arr[@]}"; do + [ -e "${data}" ] && filecount=$(("${filecount}" + 1)) done - if [ "${mcount}" == "${#mainsail_data[*]}" ]; then - MAINSAIL_STATUS="${green}Installed!${white} " - elif [ "${mcount}" == 0 ]; then - MAINSAIL_STATUS="${red}Not installed!${white} " + + if [ "${filecount}" == "${#data_arr[*]}" ]; then + status="${green}Installed!${white} " + elif [ "${filecount}" == 0 ]; then + status="${red}Not installed!${white} " else - MAINSAIL_STATUS="${yellow}Incomplete!${white} " + status="${yellow}Incomplete!${white} " fi + echo "${status}" } function get_local_mainsail_version(){ diff --git a/scripts/ui/main_menu.sh b/scripts/ui/main_menu.sh index ff95122..83da7d6 100755 --- a/scripts/ui/main_menu.sh +++ b/scripts/ui/main_menu.sh @@ -20,7 +20,7 @@ main_ui(){ echo -e "| 1) [Install] | |" echo -e "| 2) [Update] | Moonraker: $(get_moonraker_status)|" echo -e "| 3) [Remove] | |" - echo -e "| 4) [Advanced] | Mainsail: $MAINSAIL_STATUS|" + echo -e "| 4) [Advanced] | Mainsail: $(mainsail_status)|" echo -e "| 5) [Backup] | Fluidd: $FLUIDD_STATUS|" echo -e "| | KlipperScreen: $(klipperscreen_status)|" echo -e "| 6) [Settings] | Telegram Bot: $(get_telegram_bot_status)|" @@ -66,7 +66,6 @@ main_menu(){ kiauh_update_dialog #check install status fluidd_status - mainsail_status octoprint_status main_ui while true; do