From 68bedd7218fb285c5bbc6279c31f48505fc481b6 Mon Sep 17 00:00:00 2001 From: Yifei Ding Date: Sat, 13 Nov 2021 12:29:34 -0800 Subject: [PATCH] script: separate moonraker removal with whiptail --- scripts/remove.sh | 31 ++++------------------------ scripts/ui/remove_moonraker_yesno.sh | 17 +++++++++++++++ 2 files changed, 21 insertions(+), 27 deletions(-) create mode 100755 scripts/ui/remove_moonraker_yesno.sh diff --git a/scripts/remove.sh b/scripts/remove.sh index 0055b89..e632635 100755 --- a/scripts/remove.sh +++ b/scripts/remove.sh @@ -1,36 +1,13 @@ +#!/bin/bash + remove_klipper(){ + #TODO The logic to Ask if you want to remove moonraker should be outside of remove_klipper shopt -s extglob # enable extended globbing ### ask the user if he wants to uninstall moonraker too. ###? currently usefull if the user wants to switch from single-instance to multi-instance FILE="$SYSTEMD_DIR/moonraker?(-*([0-9])).service" if ls $FILE 2>/dev/null 1>&2; then - while true; do - unset REM_MR - top_border - echo -e "| Do you want to remove Moonraker afterwards? |" - echo -e "| |" - echo -e "| This is useful in case you want to switch from a |" - echo -e "| single-instance to a multi-instance installation, |" - echo -e "| which makes a re-installation of Moonraker necessary. |" - echo -e "| |" - echo -e "| If for any other reason you only want to uninstall |" - echo -e "| Klipper, please select 'No' and continue. |" - bottom_border - read -p "${cyan}###### Remove Moonraker afterwards? (y/N):${default} " yn - case "$yn" in - Y|y|Yes|yes) - echo -e "###### > Yes" - REM_MR="true" - break;; - N|n|No|no|"") - echo -e "###### > No" - REM_MR="false" - break;; - *) - print_unkown_cmd - print_msg && clear_msg;; - esac - done + remove_moonraker_yesno fi ### remove "legacy" klipper init.d service diff --git a/scripts/ui/remove_moonraker_yesno.sh b/scripts/ui/remove_moonraker_yesno.sh new file mode 100755 index 0000000..80379d0 --- /dev/null +++ b/scripts/ui/remove_moonraker_yesno.sh @@ -0,0 +1,17 @@ +#!/bin/bash +remove_moonraker_yesno(){ + whiptail --title "Remove" \ + --yesno \ + "Do you want to remove Moonraker afterwards? + + This is useful in case you want to switch from a single-instance to a multi-instance installation, which makes a re-installation of Moonraker necessary. + + If for any other reason you only want to uninstall Klipper, please select 'No' and continue." \ + "$KIAUH_WHIPTAIL_NORMAL_HEIGHT" "$KIAUH_WHIPTAIL_NORMAL_WIDTH" + + local out=$? + if [ $out -eq 0 ]; then + REM_MR="true" + else + REM_MR="false" +} \ No newline at end of file