diff --git a/scripts/globals.sh b/scripts/globals.sh index 43665aa..7b3a1b1 100644 --- a/scripts/globals.sh +++ b/scripts/globals.sh @@ -21,6 +21,7 @@ function set_globals(){ #=================== KIAUH ====================# green=$(echo -en "\e[92m") yellow=$(echo -en "\e[93m") + magenta=$(echo -en "\e[95m") red=$(echo -en "\e[91m") cyan=$(echo -en "\e[96m") white=$(echo -en "\e[39m") diff --git a/scripts/klipper.sh b/scripts/klipper.sh index 54dc677..499a427 100644 --- a/scripts/klipper.sh +++ b/scripts/klipper.sh @@ -55,11 +55,10 @@ function klipper_setup_dialog(){ top_border echo -e "| Please select the number of Klipper instances to set |" echo -e "| up. The number of Klipper instances will determine |" - echo -e "| the amount of printers you can run from this machine. |" + echo -e "| the amount of printers you can run from this host. |" blank_line - echo -e "| ${yellow}WARNING: There is no limit on the number of instances${white} |" - echo -e "| ${yellow}you can set up with this script. Setting up too many${white} |" - echo -e "| ${yellow}Klipper instances can potentially crash your system.${white} |" + echo -e "| ${yellow}WARNING:${white} |" + echo -e "| ${yellow}Setting up too many instances may crash your system.${white} |" bottom_border local count @@ -74,7 +73,8 @@ function klipper_setup_dialog(){ case "${yn}" in Y|y|Yes|yes|"") select_msg "Yes" - status_msg "Installing ${count} Klipper instance(s) ... \n" + ((count == 1)) && status_msg "Installing single Klipper instance ..." + ((count > 1)) && status_msg "Installing ${count} Klipper instances ..." klipper_setup "${count}" "${python_version}" break;; N|n|No|no) @@ -82,7 +82,7 @@ function klipper_setup_dialog(){ abort_msg "Exiting Klipper setup ...\n" break;; *) - error_msg "Invalid Input!\n";; + error_msg "Invalid Input!";; esac done fi diff --git a/scripts/ui/advanced_menu.sh b/scripts/ui/advanced_menu.sh index 2caa6c8..62da3fa 100755 --- a/scripts/ui/advanced_menu.sh +++ b/scripts/ui/advanced_menu.sh @@ -29,7 +29,7 @@ function advanced_ui(){ function advanced_menu(){ do_action "" "advanced_ui" while true; do - read -p "${cyan}Perform action:${white} " action; echo + read -p "${cyan}####### Perform action:${white} " action case "${action}" in 1) do_action "load_klipper_state" "advanced_ui";; diff --git a/scripts/ui/backup_menu.sh b/scripts/ui/backup_menu.sh index f70abd3..fef8bae 100755 --- a/scripts/ui/backup_menu.sh +++ b/scripts/ui/backup_menu.sh @@ -33,7 +33,7 @@ function backup_ui(){ function backup_menu(){ do_action "" "backup_ui" while true; do - read -p "${cyan}Perform action:${white} " action; echo + read -p "${cyan}####### Perform action:${white} " action case "${action}" in 0) do_action "backup_klipper_config_dir" "backup_ui";; diff --git a/scripts/ui/install_menu.sh b/scripts/ui/install_menu.sh index 6109590..a43d5cf 100755 --- a/scripts/ui/install_menu.sh +++ b/scripts/ui/install_menu.sh @@ -37,7 +37,7 @@ function install_menu(){ install_ui while true; do - read -p "${cyan}Perform action:${white} " action; echo + read -p "${cyan}####### Perform action:${white} " action case "${action}" in 1)clear && print_header select_klipper_python_version @@ -79,7 +79,7 @@ function select_klipper_python_version(){ echo -e "| 2) [Python 3.x] ${yellow}(experimental)${white} | " back_footer while true; do - read -p "${cyan}###### Select Python version:${white} " action; echo + read -p "${cyan}###### Select Python version:${white} " action case "${action}" in 1) select_msg "Python 2.7" diff --git a/scripts/ui/main_menu.sh b/scripts/ui/main_menu.sh index b5c786b..6d69ae0 100755 --- a/scripts/ui/main_menu.sh +++ b/scripts/ui/main_menu.sh @@ -66,7 +66,7 @@ function main_menu(){ kiauh_update_dialog main_ui while true; do - read -p "${cyan}Perform action:${white} " action; echo + read -p "${cyan}####### Perform action:${white} " action case "${action}" in "start klipper") do_action_service "start" "klipper"; main_ui;; "stop klipper") do_action_service "stop" "klipper"; main_ui;; diff --git a/scripts/ui/remove_menu.sh b/scripts/ui/remove_menu.sh index 0ab0de6..3c89096 100755 --- a/scripts/ui/remove_menu.sh +++ b/scripts/ui/remove_menu.sh @@ -15,8 +15,7 @@ function remove_ui(){ top_border echo -e "| ${red}~~~~~~~~~~~~~~ [ Remove Menu ] ~~~~~~~~~~~~~~${white} | " hr - echo -e "| ${yellow}INFO:${white} | " - echo -e "| Printer configs or backups always remain untouched! | " + echo -e "| ${yellow}INFO: Configurations and/or any backups will be kept!${white} | " hr echo -e "| Firmware: | Touchscreen GUI: | " echo -e "| 1) [Klipper] | 5) [KlipperScreen] | " @@ -33,7 +32,7 @@ function remove_ui(){ function remove_menu(){ do_action "" "remove_ui" while true; do - read -p "${cyan}Perform action:${white} " action; echo + read -p "${cyan}####### Perform action:${white} " action case "${action}" in 1) do_action "remove_klipper" "remove_ui";; diff --git a/scripts/ui/settings_menu.sh b/scripts/ui/settings_menu.sh index da370ba..40370f7 100755 --- a/scripts/ui/settings_menu.sh +++ b/scripts/ui/settings_menu.sh @@ -121,7 +121,7 @@ function settings_menu(){ clear && print_header settings_ui while true; do - read -p "${cyan}Perform action:${white} " action; echo + read -p "${cyan}####### Perform action:${white} " action case "${action}" in 1) change_klipper_cfg_folder && settings_ui;; diff --git a/scripts/ui/update_menu.sh b/scripts/ui/update_menu.sh index 893a339..94d885f 100755 --- a/scripts/ui/update_menu.sh +++ b/scripts/ui/update_menu.sh @@ -43,7 +43,7 @@ function update_menu(){ read_bb4u_stat do_action "" "update_ui" while true; do - read -p "${cyan}Perform action:${white} " action; echo + read -p "${cyan}####### Perform action:${white} " action case "${action}" in 0) do_action "toggle_backups" "update_ui";; diff --git a/scripts/utilities.sh b/scripts/utilities.sh index 46469f5..22e41f7 100644 --- a/scripts/utilities.sh +++ b/scripts/utilities.sh @@ -32,13 +32,13 @@ function check_euid(){ #================================================# function select_msg() { - echo -e "${white}>>>>>> ${1}" + echo -e "${white} [➔] ${1}" } function status_msg(){ - echo -e "${yellow}###### ${1}${white}" + echo -e "\n${magenta}###### ${1}${white}" } function ok_msg(){ - echo -e "${green}>>>>>> ${1}${white}" + echo -e "${green}[✓ OK] ${1}${white}" } function warn_msg(){ echo -e "${yellow}>>>>>> ${1}${white}" @@ -56,18 +56,18 @@ function title_msg(){ function print_error(){ [ -z "${1}" ] && return echo -e "${red}" - echo -e "#########################################################" + echo -e "#=======================================================#" echo -e " ${1} " - echo -e "#########################################################" + echo -e "#=======================================================#" echo -e "${white}" } function print_confirm(){ [ -z "${1}" ] && return echo -e "${green}" - echo -e "#########################################################" + echo -e "#=======================================================#" echo -e " ${1} " - echo -e "#########################################################" + echo -e "#=======================================================#" echo -e "${white}" } @@ -371,30 +371,32 @@ function python3_check(){ } function dependency_check(){ - local dep=( "${@}" ) # dep: array + local dep=( "${@}" ) + local packages status_msg "Checking for the following dependencies:" - #check if package is installed, if not write name into array - for pkg in "${dep[@]}" - do + #check if package is installed, if not write its name into array + for pkg in "${dep[@]}"; do echo -e "${cyan}● ${pkg} ${white}" if [[ ! $(dpkg-query -f'${Status}' --show "${pkg}" 2>/dev/null) = *\ installed ]]; then - inst+=("${pkg}") + packages+=("${pkg}") fi done - #if array is not empty, install packages from array elements - if [ "${#inst[@]}" -ne 0 ]; then + #if array is not empty, install packages from array + if (( ${#packages[@]} > 0 )); then status_msg "Installing the following dependencies:" - for element in "${inst[@]}" - do - echo -e "${cyan}● ${element} ${white}" + for package in "${packages[@]}"; do + echo -e "${cyan}● ${package} ${white}" done echo - sudo apt-get update --allow-releaseinfo-change && sudo apt-get install "${inst[@]}" -y - ok_msg "Dependencies installed!" - #clearing the array - unset inst + if sudo apt-get update --allow-releaseinfo-change && sudo apt-get install "${packages[@]}" -y; then + ok_msg "Dependencies installed!" + else + error_msg "Installing dependencies failed!" + return 1 # exit kiauh + fi else - ok_msg "Dependencies already met! Continue..." + ok_msg "Dependencies already met!" + return fi }