script: multi-layer install menu

This commit is contained in:
Yifei Ding
2021-11-13 00:42:23 -08:00
parent 4613a85ccf
commit 00fa372e0c
3 changed files with 95 additions and 50 deletions

View File

@@ -0,0 +1,36 @@
#!/bin/bash
#
# Brief description of your script
install_interface_menu(){
local menu_options=(
"1" "Mainsail - lightweight & responsive web interface for Klipper"
"2" "Fluidd - a free and open-source Klipper web interface for managing your 3d printer"
"3" "KlipperScreen - a touchscreen GUI that interfaces with Klipper via Moonraker"
"4" "Duet Web Control - a fully-responsive HTML5-based web interface for RepRapFirmware"
"5" "OctoPrint - a snappy web interface for controlling consumer 3D printers."
)
local menu_str="Select an interface to install, you can install multiple interfaces."
while true; do
local menu
menu=$(whiptail --title "Install Interface" --cancel-button "Back" --notags --menu "$menu_str\n\nPerform Action:" \
"$KIAUH_WHIPTAIL_NORMAL_HEIGHT" "$KIAUH_WHIPTAIL_NORMAL_WIDTH" 8 "${menu_options[@]}" 3>&1 1>&2 2>&3)
local out=$?
if [ $out -eq 1 ]; then
break
elif [ $out -eq 0 ]; then
case "$menu" in
1) do_action "install_webui mainsail";;
2) do_action "install_webui fluidd";;
3) do_action "install_klipperscreen";;
4) do_action "dwc_setup_dialog";;
5) do_action "octoprint_setup_dialog";;
esac
else
# Unexpected event, no clue what happened
exit 1
fi
done
}

View File

@@ -1,55 +1,31 @@
install_ui(){
top_border
echo -e "| ${green}~~~~~~~~~~~ [ Installation Menu ] ~~~~~~~~~~~${default} | "
hr
echo -e "| You need this menu usually only for installing | "
echo -e "| all necessary dependencies for the various | "
echo -e "| functions on a completely fresh system. | "
hr
echo -e "| Firmware: | Touchscreen GUI: | "
echo -e "| 1) [Klipper] | 5) [KlipperScreen] | "
echo -e "| | | "
echo -e "| Klipper API: | Other: | "
echo -e "| 2) [Moonraker] | 6) [Duet Web Control] | "
echo -e "| | 7) [OctoPrint] | "
echo -e "| Klipper Webinterface: | 8) [PrettyGCode] | "
echo -e "| 3) [Mainsail] | 9) [Telegram Bot] | "
echo -e "| 4) [Fluidd] | | "
echo -e "| | Webcam: | "
echo -e "| | 10) [MJPG-Streamer] | "
back_footer
}
#!/bin/bash
install_menu(){
do_action "" "install_ui"
local menu_options=(
"1" "Klipper"
"2" "Klipper API(Moonraker)"
"3" "Interfaces"
"4" "Other"
)
local menu_str="You need this menu usually only for installing all necessary dependencies for the various functions on a completely fresh system."
while true; do
read -p "${cyan}Perform action:${default} " action; echo
case "$action" in
1)
do_action "klipper_setup_dialog" "install_ui";;
2)
do_action "moonraker_setup_dialog" "install_ui";;
3)
do_action "install_webui mainsail" "install_ui";;
4)
do_action "install_webui fluidd" "install_ui";;
5)
do_action "install_klipperscreen" "install_ui";;
6)
do_action "dwc_setup_dialog" "install_ui";;
7)
do_action "octoprint_setup_dialog" "install_ui";;
8)
do_action "install_pgc_for_klipper" "install_ui";;
9)
do_action "install_MoonrakerTelegramBot" "install_ui";;
10)
do_action "install_mjpg-streamer" "install_ui";;
B|b)
clear; main_menu; break;;
*)
deny_action "install_ui";;
esac
local menu
menu=$(whiptail --title "Install" --cancel-button "Back" --notags --menu "$menu_str\n\nPerform Action:" \
"$KIAUH_WHIPTAIL_NORMAL_HEIGHT" "$KIAUH_WHIPTAIL_NORMAL_WIDTH" 8 "${menu_options[@]}" 3>&1 1>&2 2>&3)
local out=$?
if [ $out -eq 1 ]; then
break
elif [ $out -eq 0 ]; then
case "$menu" in
1) do_action "klipper_setup_dialog";;
2) do_action "moonraker_setup_dialog";;
3) install_interface_menu;;
4) install_other_menu;;
esac
else
# Unexpected event, no clue what happened
exit 1
fi
done
install_menu
}

View File

@@ -0,0 +1,33 @@
#!/bin/bash
#
# Brief description of your script
install_other_menu(){
local menu_options=(
#TODO WIP
"1" "PrettyGCode - "
"2" "Klipper Telegram Bot - "
"3" "Webcam MJPG-Streamer - Use MJPG-Streamer with webcam"
)
local menu_str="Select an option to install."
while true; do
local menu
menu=$(whiptail --title "Install Other" --cancel-button "Back" --notags --menu "$menu_str\n\nPerform Action:" \
"$KIAUH_WHIPTAIL_NORMAL_HEIGHT" "$KIAUH_WHIPTAIL_NORMAL_WIDTH" 8 "${menu_options[@]}" 3>&1 1>&2 2>&3)
local out=$?
if [ $out -eq 1 ]; then
break
elif [ $out -eq 0 ]; then
case "$menu" in
1) do_action "install_pgc_for_klipper";;
2) do_action "install_MoonrakerTelegramBot";;
3) do_action "install_mjpg-streamer";;
esac
else
# Unexpected event, no clue what happened
exit 1
fi
done
}