mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-14 19:14:27 +05:00
fix: make adding the kiauh_macros optional
This commit is contained in:
@@ -1,6 +1,12 @@
|
|||||||
### AUTOCREATED WITH KIAUH ###
|
#########################################################################################
|
||||||
#is required to load the pause_resume module in klipper
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ AUTOCREATED WITH KIAUH ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
|
||||||
|
#########################################################################################
|
||||||
|
# Those are the recommended macros and config entries if you use Mainsail or Fluidd! #
|
||||||
|
# Feel free to edit or delete those macros if you already have them defined elsewhere! #
|
||||||
|
#########################################################################################
|
||||||
|
|
||||||
[pause_resume]
|
[pause_resume]
|
||||||
|
[display_status]
|
||||||
|
|
||||||
[gcode_macro PAUSE]
|
[gcode_macro PAUSE]
|
||||||
rename_existing: BASE_PAUSE
|
rename_existing: BASE_PAUSE
|
||||||
@@ -34,5 +40,6 @@ gcode:
|
|||||||
CLEAR_PAUSE
|
CLEAR_PAUSE
|
||||||
SDCARD_RESET_FILE
|
SDCARD_RESET_FILE
|
||||||
BASE_CANCEL_PRINT
|
BASE_CANCEL_PRINT
|
||||||
##########################
|
|
||||||
##########################
|
#########################################################################################
|
||||||
|
#########################################################################################
|
||||||
|
|||||||
@@ -114,8 +114,6 @@ MULTI_STARTSCRIPT
|
|||||||
|
|
||||||
create_minimal_printer_cfg(){
|
create_minimal_printer_cfg(){
|
||||||
/bin/sh -c "cat > $1" << MINIMAL_CFG
|
/bin/sh -c "cat > $1" << MINIMAL_CFG
|
||||||
[include kiauh_macros.cfg]
|
|
||||||
|
|
||||||
[mcu]
|
[mcu]
|
||||||
serial: /dev/serial/by-id/
|
serial: /dev/serial/by-id/
|
||||||
pin_map: arduino
|
pin_map: arduino
|
||||||
@@ -182,7 +180,6 @@ create_single_klipper_instance(){
|
|||||||
|
|
||||||
### create basic configs if missing
|
### create basic configs if missing
|
||||||
[ ! -f $PRINTER_CFG ] && create_minimal_printer_cfg "$PRINTER_CFG"
|
[ ! -f $PRINTER_CFG ] && create_minimal_printer_cfg "$PRINTER_CFG"
|
||||||
[ ! -f $PRINTER_CFG_LOC/kiauh_macros.cfg ] && cp ${SRCDIR}/kiauh/resources/kiauh_macros.cfg $PRINTER_CFG_LOC/kiauh_macros.cfg
|
|
||||||
|
|
||||||
### enable instance
|
### enable instance
|
||||||
sudo systemctl enable klipper.service
|
sudo systemctl enable klipper.service
|
||||||
@@ -215,7 +212,6 @@ create_multi_klipper_instance(){
|
|||||||
|
|
||||||
### create basic configs if missing
|
### create basic configs if missing
|
||||||
[ ! -f $PRINTER_CFG ] && create_minimal_printer_cfg "$PRINTER_CFG"
|
[ ! -f $PRINTER_CFG ] && create_minimal_printer_cfg "$PRINTER_CFG"
|
||||||
[ ! -f $PRINTER_CFG_LOC/printer_$INSTANCE/kiauh_macros.cfg ] && cp ${SRCDIR}/kiauh/resources/kiauh_macros.cfg $PRINTER_CFG_LOC/printer_$INSTANCE/kiauh_macros.cfg
|
|
||||||
|
|
||||||
### enable instance
|
### enable instance
|
||||||
sudo systemctl enable klipper-$INSTANCE.service
|
sudo systemctl enable klipper-$INSTANCE.service
|
||||||
|
|||||||
@@ -10,39 +10,39 @@ check_moonraker(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# get_user_selection_webui(){
|
get_user_selection_kiauh_macros(){
|
||||||
# #ask user for webui default macros
|
#ask user for webui default macros
|
||||||
# while true; do
|
while true; do
|
||||||
# unset ADD_WEBUI_MACROS
|
unset ADD_KIAUH_MACROS
|
||||||
# echo
|
echo
|
||||||
# top_border
|
top_border
|
||||||
# echo -e "| It is recommended to have some important macros to |"
|
echo -e "| It is recommended to have some important macros to |"
|
||||||
# echo -e "| have full functionality of the web interface. |"
|
echo -e "| have full functionality of the web interface. |"
|
||||||
# blank_line
|
blank_line
|
||||||
# echo -e "| If you do not have such macros, you can choose to |"
|
echo -e "| If you don't have those macros, you can choose to |"
|
||||||
# echo -e "| install the suggested default macros now. |"
|
echo -e "| install suggested default macros now. |"
|
||||||
# bottom_border
|
blank_line
|
||||||
# read -p "${cyan}###### Add the recommended macros? (Y/n):${default} " yn
|
echo -e "| If unsure which macros are meant, just go ahead and |"
|
||||||
# case "$yn" in
|
echo -e "| select 'Yes'. You can always delete them later. |"
|
||||||
# Y|y|Yes|yes|"")
|
bottom_border
|
||||||
# echo -e "###### > Yes"
|
read -p "${cyan}###### Add the recommended macros? (Y/n):${default} " yn
|
||||||
# ADD_WEBUI_MACROS="true"
|
case "$yn" in
|
||||||
# break;;
|
Y|y|Yes|yes|"")
|
||||||
# N|n|No|no)
|
echo -e "###### > Yes"
|
||||||
# echo -e "###### > No"
|
ADD_KIAUH_MACROS="true"
|
||||||
# ADD_WEBUI_MACROS="false"
|
break;;
|
||||||
# break;;
|
N|n|No|no)
|
||||||
# *)
|
echo -e "###### > No"
|
||||||
# print_unkown_cmd
|
ADD_KIAUH_MACROS="false"
|
||||||
# print_msg && clear_msg;;
|
break;;
|
||||||
# esac
|
*)
|
||||||
# done
|
print_unkown_cmd
|
||||||
# }
|
print_msg && clear_msg;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
install_mainsail(){
|
install_mainsail(){
|
||||||
###! outdated dialog, see comment below regarding webui macros
|
|
||||||
#get_user_selection_webui
|
|
||||||
|
|
||||||
### check if moonraker is already installed
|
### check if moonraker is already installed
|
||||||
check_moonraker
|
check_moonraker
|
||||||
|
|
||||||
@@ -54,16 +54,17 @@ install_mainsail(){
|
|||||||
### check if another site already listens to port 80
|
### check if another site already listens to port 80
|
||||||
mainsail_port_check
|
mainsail_port_check
|
||||||
|
|
||||||
|
### ask user to install the recommended webinterface macros
|
||||||
|
get_user_selection_kiauh_macros
|
||||||
|
|
||||||
### ask user to enable the moonraker update manager
|
### ask user to enable the moonraker update manager
|
||||||
enable_update_manager "mainsail"
|
enable_update_manager "mainsail"
|
||||||
|
|
||||||
### creating the mainsail nginx cfg
|
### creating the mainsail nginx cfg
|
||||||
set_nginx_cfg "mainsail"
|
set_nginx_cfg "mainsail"
|
||||||
|
|
||||||
###! outdated way of locating the printer.cfg. need a new way to install the webui-macros
|
### copy the kiauh_macros.cfg to the config location
|
||||||
###! especially for multi instances, therefore disabling this function for now...
|
install_kiauh_macros
|
||||||
#locate_printer_cfg && read_printer_cfg "mainsail"
|
|
||||||
#install_webui_macros
|
|
||||||
|
|
||||||
### install mainsail
|
### install mainsail
|
||||||
mainsail_setup
|
mainsail_setup
|
||||||
@@ -71,9 +72,6 @@ install_mainsail(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
install_fluidd(){
|
install_fluidd(){
|
||||||
###! outdated dialog, see comment below regarding webui macros
|
|
||||||
#get_user_selection_webui
|
|
||||||
|
|
||||||
### check if moonraker is already installed
|
### check if moonraker is already installed
|
||||||
check_moonraker
|
check_moonraker
|
||||||
|
|
||||||
@@ -85,35 +83,58 @@ install_fluidd(){
|
|||||||
### check if another site already listens to port 80
|
### check if another site already listens to port 80
|
||||||
fluidd_port_check
|
fluidd_port_check
|
||||||
|
|
||||||
|
### ask user to install the recommended webinterface macros
|
||||||
|
get_user_selection_kiauh_macros
|
||||||
|
|
||||||
### ask user to enable the moonraker update manager
|
### ask user to enable the moonraker update manager
|
||||||
enable_update_manager "fluidd"
|
enable_update_manager "fluidd"
|
||||||
|
|
||||||
### creating the fluidd nginx cfg
|
### creating the fluidd nginx cfg
|
||||||
set_nginx_cfg "fluidd"
|
set_nginx_cfg "fluidd"
|
||||||
|
|
||||||
###! outdated way of locating the printer.cfg. need a new way to install the webui-macros
|
### copy the kiauh_macros.cfg to the config location
|
||||||
###! especially for multi instances, therefore disabling this function for now...
|
install_kiauh_macros
|
||||||
#locate_printer_cfg && read_printer_cfg "fluidd"
|
|
||||||
#install_webui_macros
|
|
||||||
|
|
||||||
### install fluidd
|
### install fluidd
|
||||||
fluidd_setup
|
fluidd_setup
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# install_webui_macros(){
|
install_kiauh_macros(){
|
||||||
# #copy webui_macros.cfg
|
source_kiauh_ini
|
||||||
# if [ "$ADD_WEBUI_MACROS" = "true" ]; then
|
### copy kiauh_macros.cfg
|
||||||
# status_msg "Create webui_macros.cfg ..."
|
if [ "$ADD_KIAUH_MACROS" = "true" ]; then
|
||||||
# if [ ! -f ${HOME}/klipper_config/webui_macros.cfg ]; then
|
### create a backup of the config folder
|
||||||
# cp ${HOME}/kiauh/resources/webui_macros.cfg ${HOME}/klipper_config
|
backup_klipper_config_dir
|
||||||
# ok_msg "File created!"
|
|
||||||
# else
|
### handle single printer.cfg
|
||||||
# warn_msg "File already exists! Skipping ..."
|
if [ -f $klipper_cfg_loc/printer.cfg ] && [ ! -f $klipper_cfg_loc/kiauh_macros.cfg ]; then
|
||||||
# fi
|
### copy kiauh_macros.cfg to config location
|
||||||
# fi
|
cp ${SRCDIR}/kiauh/resources/kiauh_macros.cfg $klipper_cfg_loc
|
||||||
# write_printer_cfg
|
ok_msg "$klipper_cfg_loc/kiauh_macros.cfg created!"
|
||||||
# }
|
|
||||||
|
### write the include to the very first line of the printer.cfg
|
||||||
|
sed -i "1 i [include kiauh_macros.cfg]" $klipper_cfg_loc/printer.cfg
|
||||||
|
fi
|
||||||
|
|
||||||
|
### handle multi printer.cfg
|
||||||
|
if ls $klipper_cfg_loc/printer_* 2>/dev/null 1>&2; then
|
||||||
|
for config in $(find $klipper_cfg_loc/printer_*/printer.cfg); do
|
||||||
|
path=$(echo $config | rev | cut -d"/" -f2- | rev)
|
||||||
|
if [ ! -f $path/kiauh_macros.cfg ]; then
|
||||||
|
### copy kiauh_macros.cfg to config location
|
||||||
|
cp ${SRCDIR}/kiauh/resources/kiauh_macros.cfg $path
|
||||||
|
ok_msg "$path/kiauh_macros.cfg created!"
|
||||||
|
|
||||||
|
### write the include to the very first line of the printer.cfg
|
||||||
|
sed -i "1 i [include kiauh_macros.cfg]" $path/printer.cfg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
### restart klipper service to parse the modified printer.cfg
|
||||||
|
klipper_service "restart"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
mainsail_port_check(){
|
mainsail_port_check(){
|
||||||
if [ "$MAINSAIL_ENABLED" = "false" ]; then
|
if [ "$MAINSAIL_ENABLED" = "false" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user