mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-13 10:34:28 +05:00
Add Octoprint Service toggle function and a new confirm message
This commit is contained in:
93
kiauh.sh
93
kiauh.sh
@@ -66,7 +66,7 @@ BRANCH_DEV_MOONRAKER=Arksine/dev-moonraker-testing
|
|||||||
BRANCH_SCURVE_SMOOTHING=dmbutyugin/scurve-smoothing
|
BRANCH_SCURVE_SMOOTHING=dmbutyugin/scurve-smoothing
|
||||||
BRANCH_SCURVE_SHAPING=dmbutyugin/scurve-shaping
|
BRANCH_SCURVE_SHAPING=dmbutyugin/scurve-shaping
|
||||||
|
|
||||||
print_error_msg(){
|
print_msg(){
|
||||||
if [[ "$ERROR_MSG" != "" ]]; then
|
if [[ "$ERROR_MSG" != "" ]]; then
|
||||||
echo -e "${red}"
|
echo -e "${red}"
|
||||||
echo -e "#########################################################"
|
echo -e "#########################################################"
|
||||||
@@ -74,11 +74,18 @@ print_error_msg(){
|
|||||||
echo -e "#########################################################"
|
echo -e "#########################################################"
|
||||||
echo -e "${default}"
|
echo -e "${default}"
|
||||||
fi
|
fi
|
||||||
|
if [ "$CONFIRM_MSG" != "" ]; then
|
||||||
|
echo -e "${green}"
|
||||||
|
echo -e "#########################################################"
|
||||||
|
echo -e "$CONFIRM_MSG "
|
||||||
|
echo -e "#########################################################"
|
||||||
|
echo -e "${default}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main_menu(){
|
main_menu(){
|
||||||
print_header
|
print_header
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
#check install status
|
#check install status
|
||||||
klipper_status
|
klipper_status
|
||||||
dwc2_status
|
dwc2_status
|
||||||
@@ -93,7 +100,7 @@ main_menu(){
|
|||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
ERROR_MSG=" Sorry this function is not implemented yet!"
|
ERROR_MSG=" Sorry this function is not implemented yet!"
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
main_ui;;
|
main_ui;;
|
||||||
1)
|
1)
|
||||||
clear
|
clear
|
||||||
@@ -115,7 +122,7 @@ main_menu(){
|
|||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
ERROR_MSG=" Sorry this function is not implemented yet!"
|
ERROR_MSG=" Sorry this function is not implemented yet!"
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
main_ui;;
|
main_ui;;
|
||||||
Q|q)
|
Q|q)
|
||||||
exit -1;;
|
exit -1;;
|
||||||
@@ -123,7 +130,7 @@ main_menu(){
|
|||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
ERROR_MSG=" Unknown command '$action'"
|
ERROR_MSG=" Unknown command '$action'"
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
main_ui;;
|
main_ui;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@@ -140,25 +147,25 @@ install_menu(){
|
|||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
install_klipper
|
install_klipper
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
install_ui;;
|
install_ui;;
|
||||||
2)
|
2)
|
||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
dwc2_install_routine
|
dwc2_install_routine
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
install_ui;;
|
install_ui;;
|
||||||
3)
|
3)
|
||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
mainsail_install_routine
|
mainsail_install_routine
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
install_ui;;
|
install_ui;;
|
||||||
4)
|
4)
|
||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
octoprint_install_routine
|
octoprint_install_routine
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
install_ui;;
|
install_ui;;
|
||||||
Q|q)
|
Q|q)
|
||||||
clear; main_menu; break;;
|
clear; main_menu; break;;
|
||||||
@@ -166,7 +173,7 @@ install_menu(){
|
|||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
ERROR_MSG=" Unknown command '$action'"
|
ERROR_MSG=" Unknown command '$action'"
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
install_ui;;
|
install_ui;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@@ -186,31 +193,31 @@ update_menu(){
|
|||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
toggle_backups
|
toggle_backups
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
update_ui;;
|
update_ui;;
|
||||||
1)
|
1)
|
||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
update_klipper && ui_print_versions
|
update_klipper && ui_print_versions
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
update_ui;;
|
update_ui;;
|
||||||
2)
|
2)
|
||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
update_dwc2fk && ui_print_versions
|
update_dwc2fk && ui_print_versions
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
update_ui;;
|
update_ui;;
|
||||||
3)
|
3)
|
||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
update_dwc2 && ui_print_versions
|
update_dwc2 && ui_print_versions
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
update_ui;;
|
update_ui;;
|
||||||
4)
|
4)
|
||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
update_mainsail && ui_print_versions
|
update_mainsail && ui_print_versions
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
update_ui;;
|
update_ui;;
|
||||||
Q|q)
|
Q|q)
|
||||||
clear; main_menu; break;;
|
clear; main_menu; break;;
|
||||||
@@ -218,7 +225,7 @@ update_menu(){
|
|||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
ERROR_MSG=" Unknown command '$action'"
|
ERROR_MSG=" Unknown command '$action'"
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
ui_print_versions
|
ui_print_versions
|
||||||
update_ui;;
|
update_ui;;
|
||||||
esac
|
esac
|
||||||
@@ -236,25 +243,25 @@ remove_menu(){
|
|||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
remove_klipper
|
remove_klipper
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
remove_ui;;
|
remove_ui;;
|
||||||
2)
|
2)
|
||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
remove_dwc2
|
remove_dwc2
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
remove_ui;;
|
remove_ui;;
|
||||||
3)
|
3)
|
||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
remove_mainsail
|
remove_mainsail
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
remove_ui;;
|
remove_ui;;
|
||||||
4)
|
4)
|
||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
remove_octoprint
|
remove_octoprint
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
remove_ui;;
|
remove_ui;;
|
||||||
Q|q)
|
Q|q)
|
||||||
clear; main_menu; break;;
|
clear; main_menu; break;;
|
||||||
@@ -262,7 +269,7 @@ remove_menu(){
|
|||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
ERROR_MSG=" Unknown command '$action'"
|
ERROR_MSG=" Unknown command '$action'"
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
remove_ui;;
|
remove_ui;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@@ -271,45 +278,54 @@ remove_menu(){
|
|||||||
|
|
||||||
advanced_menu(){
|
advanced_menu(){
|
||||||
print_header
|
print_header
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
|
read_octoprint_service_status
|
||||||
advanced_ui
|
advanced_ui
|
||||||
while true; do
|
while true; do
|
||||||
read -p "Perform action: " action; echo
|
read -p "Perform action: " action; echo
|
||||||
case "$action" in
|
case "$action" in
|
||||||
|
0)
|
||||||
|
clear
|
||||||
|
print_header
|
||||||
|
toggle_octoprint_service
|
||||||
|
read_octoprint_service_status
|
||||||
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
|
advanced_ui;;
|
||||||
1)
|
1)
|
||||||
clear
|
clear
|
||||||
|
print_header
|
||||||
switch_menu
|
switch_menu
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
advanced_ui;;
|
advanced_ui;;
|
||||||
2)
|
2)
|
||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
build_fw
|
build_fw
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
advanced_ui;;
|
advanced_ui;;
|
||||||
3)
|
3)
|
||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
flash_routine
|
flash_routine
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
advanced_ui;;
|
advanced_ui;;
|
||||||
4)
|
4)
|
||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
get_usb_id
|
get_usb_id
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
advanced_ui;;
|
advanced_ui;;
|
||||||
5)
|
5)
|
||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
get_usb_id && write_printer_id
|
get_usb_id && write_printer_id
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
advanced_ui;;
|
advanced_ui;;
|
||||||
6)
|
6)
|
||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
create_dwc2fk_cfg
|
create_dwc2fk_cfg
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
advanced_ui;;
|
advanced_ui;;
|
||||||
Q|q)
|
Q|q)
|
||||||
clear; main_menu; break;;
|
clear; main_menu; break;;
|
||||||
@@ -317,7 +333,7 @@ advanced_menu(){
|
|||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
ERROR_MSG=" Unknown command '$action'"
|
ERROR_MSG=" Unknown command '$action'"
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
advanced_ui;;
|
advanced_ui;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@@ -325,10 +341,9 @@ advanced_menu(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch_menu(){
|
switch_menu(){
|
||||||
print_header
|
|
||||||
if [ -d $KLIPPER_DIR ]; then
|
if [ -d $KLIPPER_DIR ]; then
|
||||||
read_branch
|
read_branch
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
switch_ui
|
switch_ui
|
||||||
while true; do
|
while true; do
|
||||||
read -p "Perform action: " action; echo
|
read -p "Perform action: " action; echo
|
||||||
@@ -338,35 +353,35 @@ switch_menu(){
|
|||||||
print_header
|
print_header
|
||||||
switch_to_origin
|
switch_to_origin
|
||||||
read_branch
|
read_branch
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
switch_ui;;
|
switch_ui;;
|
||||||
2)
|
2)
|
||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
switch_to_scurve_shaping
|
switch_to_scurve_shaping
|
||||||
read_branch
|
read_branch
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
switch_ui;;
|
switch_ui;;
|
||||||
3)
|
3)
|
||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
switch_to_scurve_smoothing
|
switch_to_scurve_smoothing
|
||||||
read_branch
|
read_branch
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
switch_ui;;
|
switch_ui;;
|
||||||
4)
|
4)
|
||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
switch_to_moonraker
|
switch_to_moonraker
|
||||||
read_branch
|
read_branch
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
switch_ui;;
|
switch_ui;;
|
||||||
5)
|
5)
|
||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
switch_to_dev_moonraker
|
switch_to_dev_moonraker
|
||||||
read_branch
|
read_branch
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
switch_ui;;
|
switch_ui;;
|
||||||
Q|q)
|
Q|q)
|
||||||
clear; advanced_menu; break;;
|
clear; advanced_menu; break;;
|
||||||
@@ -379,7 +394,7 @@ switch_menu(){
|
|||||||
|
|
||||||
backup_menu(){
|
backup_menu(){
|
||||||
print_header
|
print_header
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
backup_ui
|
backup_ui
|
||||||
while true; do
|
while true; do
|
||||||
read -p "Perform action: " action; echo
|
read -p "Perform action: " action; echo
|
||||||
@@ -388,7 +403,7 @@ backup_menu(){
|
|||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
#function goes here
|
#function goes here
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
backup_ui;;
|
backup_ui;;
|
||||||
Q|q)
|
Q|q)
|
||||||
clear; main_menu; break;;
|
clear; main_menu; break;;
|
||||||
@@ -396,7 +411,7 @@ backup_menu(){
|
|||||||
clear
|
clear
|
||||||
print_header
|
print_header
|
||||||
ERROR_MSG=" Unknown command '$action'"
|
ERROR_MSG=" Unknown command '$action'"
|
||||||
print_error_msg && ERROR_MSG=""
|
print_msg && CONFIRM_MSG="" && ERROR_MSG=""
|
||||||
backup_ui;;
|
backup_ui;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -219,3 +219,25 @@ flash_mcu(){
|
|||||||
fi
|
fi
|
||||||
start_klipper
|
start_klipper
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggle_octoprint_service(){
|
||||||
|
if systemctl is-enabled octoprint.service -q; then
|
||||||
|
status_msg "Service is enabled! Disabling now ..."
|
||||||
|
sudo systemctl stop octoprint && sudo systemctl disable octoprint -q
|
||||||
|
sleep 2
|
||||||
|
CONFIRM_MSG=" Octoprint Service is now >>> DISABLED <<< !"
|
||||||
|
else
|
||||||
|
status_msg "Service is disabled! Enabling now ..."
|
||||||
|
sudo systemctl enable octoprint -q && sudo systemctl start octoprint
|
||||||
|
sleep 2
|
||||||
|
CONFIRM_MSG=" Octoprint Service is now >>> ENABLED <<< !"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
read_octoprint_service_status(){
|
||||||
|
if ! systemctl is-enabled octoprint.service -q; then
|
||||||
|
OPRINT_SERVICE_STATUS="${green}[Enable]${default} Octoprint service "
|
||||||
|
else
|
||||||
|
OPRINT_SERVICE_STATUS="${red}[Disable]${default} Octoprint service "
|
||||||
|
fi
|
||||||
|
}
|
||||||
@@ -105,6 +105,9 @@ advanced_ui(){
|
|||||||
top_border
|
top_border
|
||||||
echo -e "| $(title_msg "~~~~~~~~~~~~~ [ Advanced Menu ] ~~~~~~~~~~~~~") | "
|
echo -e "| $(title_msg "~~~~~~~~~~~~~ [ Advanced Menu ] ~~~~~~~~~~~~~") | "
|
||||||
hr
|
hr
|
||||||
|
echo -e "| 0) $OPRINT_SERVICE_STATUS| "
|
||||||
|
hr
|
||||||
|
echo -e "| | "
|
||||||
echo -e "| 1) [Switch Klipper version] | "
|
echo -e "| 1) [Switch Klipper version] | "
|
||||||
echo -e "| | "
|
echo -e "| | "
|
||||||
echo -e "| 2) [Build Firmware] | "
|
echo -e "| 2) [Build Firmware] | "
|
||||||
@@ -113,8 +116,6 @@ advanced_ui(){
|
|||||||
echo -e "| 5) [Write Printer-ID to printer.cfg] | "
|
echo -e "| 5) [Write Printer-ID to printer.cfg] | "
|
||||||
echo -e "| 6) [Write DWC2-for-klipper config] | "
|
echo -e "| 6) [Write DWC2-for-klipper config] | "
|
||||||
echo -e "| | "
|
echo -e "| | "
|
||||||
echo -e "| x) [Enable/Disable Octoprint service] | "
|
|
||||||
echo -e "| | "
|
|
||||||
quit_footer
|
quit_footer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user