script: separate moonraker removal with whiptail

This commit is contained in:
Yifei Ding
2021-11-13 12:29:34 -08:00
parent 17ca9e50a0
commit 68bedd7218
2 changed files with 21 additions and 27 deletions

View File

@@ -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

View File

@@ -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"
}