refactor(kiauh.sh): improve kiauh update routine

Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
th33xitus
2022-04-02 12:03:52 +02:00
parent e06b06c3ea
commit 52cb40ac89
5 changed files with 55 additions and 56 deletions

View File

@@ -12,13 +12,12 @@
set -e
main_ui(){
#[ $KIAUH_UPDATE_REMIND="true" ] && kiauh_update_reminder
top_border
echo -e "| $(title_msg "~~~~~~~~~~~~~~~ [ Main Menu ] ~~~~~~~~~~~~~~~") |"
hr
echo -e "| 0) [Upload Log] | Klipper: $(get_klipper_status)|"
echo -e "| | |"
echo -e "| 1) [Install] |--------------------------------|"
echo -e "| 1) [Install] | |"
echo -e "| 2) [Update] | Moonraker: $(get_moonraker_status)|"
echo -e "| 3) [Remove] | |"
echo -e "| 4) [Advanced] | Mainsail: $MAINSAIL_STATUS|"
@@ -26,21 +25,31 @@ main_ui(){
echo -e "| | KlipperScreen: $KLIPPERSCREEN_STATUS|"
echo -e "| 6) [Settings] | Telegram Bot: $MOONRAKER_TELEGRAM_BOT_STATUS|"
echo -e "| | |"
echo -e "| ${cyan}${KIAUH_VER}${white}| Octoprint: $OCTOPRINT_STATUS|"
echo -e "| $(get_kiauh_version)| Octoprint: $OCTOPRINT_STATUS|"
quit_footer
}
print_kiauh_version(){
cd ${SRCDIR}/kiauh
KIAUH_VER=$(git describe HEAD --always --tags | cut -d "-" -f 1,2)
KIAUH_VER="$(printf "%-20s" "$KIAUH_VER")"
get_kiauh_version(){
local version
cd "${SRCDIR}/kiauh"
version="$(printf "%-20s" "$(git describe HEAD --always --tags | cut -d "-" -f 1,2)")"
echo "${cyan}${version}${white}"
}
kiauh_update_dialog(){
kiauh_update_msg
read -p "${cyan}Do you want to update now? (Y/n):${default} " yn
[ ! "$(kiauh_update_avail)" == "true" ] && return
top_border
echo -e "|${green} New KIAUH update available! ${white}| "
hr
echo -e "|${green} View Changelog: https://git.io/JnmlX ${white}| "
blank_line
echo -e "|${yellow} It is recommended to keep KIAUH up to date. Updates ${white}| "
echo -e "|${yellow} usually contain bugfixes, important changes or new ${white}| "
echo -e "|${yellow} features. Please consider updating! ${white}| "
bottom_border
read -p "${cyan}Do you want to update now? (Y/n):${white} " yn
while true; do
case "$yn" in
case "${yn}" in
Y|y|Yes|yes|"")
do_action "update_kiauh"
break;;
@@ -53,24 +62,18 @@ kiauh_update_dialog(){
main_menu(){
print_header
#print KIAUH update msg if update available
if [ "$KIAUH_UPDATE_AVAIL" = "true" ]; then
kiauh_update_dialog
fi
#prompt for KIAUH update if update available
kiauh_update_dialog
#check install status
print_kiauh_version
# klipper_status
# moonraker_status
fluidd_status
mainsail_status
octoprint_status
klipperscreen_status
MoonrakerTelegramBot_status
# print_branch
print_msg && clear_msg
main_ui
while true; do
read -p "${cyan}Perform action:${default} " action; echo
read -p "${cyan}Perform action:${white} " action; echo
case "${action}" in
"start klipper") do_action_service "start" "klipper"; main_ui;;
"stop klipper") do_action_service "stop" "klipper"; main_ui;;
@@ -90,7 +93,7 @@ main_menu(){
5) clear && backup_menu && break;;
6) clear && settings_menu && break;;
Q|q)
echo -e "${green}###### Happy printing! ######${default}"; echo
echo -e "${green}###### Happy printing! ######${white}"; echo
exit 0;;
*)
deny_action "main_ui";;