fix: rework klipper webui installers

This commit is contained in:
th33xitus
2020-10-28 20:39:34 +01:00
parent be2734e640
commit b48319e24d
6 changed files with 295 additions and 310 deletions

View File

@@ -1,6 +1,4 @@
##########################
### CREATED WITH KIAUH ###
##########################
### AUTOCREATED WITH KIAUH ###
#is required to load the pause_resume module in klipper
[pause_resume]
@@ -31,14 +29,8 @@ gcode:
[gcode_macro CANCEL_PRINT]
rename_existing: BASE_CANCEL_PRINT
default_parameter_X: 230 #edit to your park position
default_parameter_Y: 230 #edit to your park position
default_parameter_Z: 10 #edit to your park position
gcode:
M104 S0
M140 S0
M141 S0
M106 S0
TURN_OFF_HEATERS
CLEAR_PAUSE
SDCARD_RESET_FILE
BASE_CANCEL_PRINT

View File

@@ -1,94 +0,0 @@
install_fluidd(){
if [ "$INST_FLUIDD" = "true" ]; then
#check if moonraker is already installed
check_moonraker
if [ "$MOONRAKER_SERVICE_FOUND" = "true" ]; then
#check for other enabled web interfaces
unset SET_LISTEN_PORT
detect_enabled_sites
#check if another site already listens to port 80
fluidd_port_check
#creating the fluidd nginx cfg
set_nginx_cfg "fluidd"
test_nginx "$SET_LISTEN_PORT"
fluidd_setup
fi
fi
}
fluidd_port_check(){
if [ "$FLUIDD_ENABLED" = "false" ]; then
if [ "$SITE_ENABLED" = "true" ]; then
status_msg "Detected other enabled interfaces:"
[ "$OCTOPRINT_ENABLED" = "true" ] && echo " ${cyan}● OctoPrint - Port: $OCTOPRINT_PORT${default}"
[ "$MAINSAIL_ENABLED" = "true" ] && echo " ${cyan}● Mainsail - Port: $MAINSAIL_PORT${default}"
[ "$DWC2_ENABLED" = "true" ] && echo " ${cyan}● DWC2 - Port: $DWC2_PORT${default}"
if [ "$MAINSAIL_PORT" = "80" ] || [ "$DWC2_PORT" = "80" ] || [ "$OCTOPRINT_PORT" = "80" ]; then
PORT_80_BLOCKED="true"
select_fluidd_port
fi
else
DEFAULT_PORT=$(grep listen ${SRCDIR}/kiauh/resources/fluidd_nginx.cfg | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
SET_LISTEN_PORT=$DEFAULT_PORT
fi
SET_NGINX_CFG="true"
else
SET_NGINX_CFG="false"
fi
}
select_fluidd_port(){
if [ "$PORT_80_BLOCKED" = "true" ]; then
echo
top_border
echo -e "| ${red}!!!WARNING!!!${default} |"
echo -e "| ${red}You need to choose a different port for Fluidd!${default} |"
echo -e "| ${red}The following web interface is listening at port 80:${default} |"
blank_line
[ "$OCTOPRINT_PORT" = "80" ] && echo "| ● OctoPrint |"
[ "$MAINSAIL_PORT" = "80" ] && echo "| ● Mainsail |"
[ "$DWC2_PORT" = "80" ] && echo "| ● DWC2 |"
blank_line
echo -e "| Make sure you don't choose a port which was already |"
echo -e "| assigned to one of the other web interfaces! |"
blank_line
echo -e "| Be aware: there is ${red}NO${default} sanity check for the following |"
echo -e "| input. So make sure to choose a valid port! |"
bottom_border
while true; do
read -p "${cyan}Please enter a new Port:${default} " NEW_PORT
if [ "$NEW_PORT" != "$MAINSAIL_PORT" ] && [ "$NEW_PORT" != "$DWC2_PORT" ] && [ "$NEW_PORT" != "$OCTOPRINT_PORT" ]; then
echo "Setting port $NEW_PORT for Fluidd!"
SET_LISTEN_PORT=$NEW_PORT
break
else
echo "That port is already taken! Select a different one!"
fi
done
fi
}
get_fluidd_ver(){
FLUIDD_VERSION=$(curl -s https://api.github.com/repositories/295836951/releases/latest | grep tag_name | cut -d'"' -f4 | cut -d"v" -f2)
}
fluidd_setup(){
#get fluidd download url
FLUIDD_DL_URL=$(curl -s https://api.github.com/repositories/295836951/releases/latest | grep browser_download_url | cut -d'"' -f4)
#clean up an existing fluidd folder
[ -d $FLUIDD_DIR ] && rm -rf $FLUIDD_DIR
#create fresh fluidd folder and download fluidd
mkdir $FLUIDD_DIR && cd $FLUIDD_DIR
status_msg "Downloading Fluidd $FLUIDD_VERSION ..."
wget $FLUIDD_DL_URL && ok_msg "Download complete!"
#extract archive
status_msg "Unzipping archive ..."
unzip -q -o *.zip && ok_msg "Done!"
#write fluidd version to file for update check reasons
status_msg "Writing Fluidd version to file ..."
get_fluidd_ver && echo $FLUIDD_VERSION > $FLUIDD_DIR/version && ok_msg "Done!"
#delete downloaded zip
status_msg "Do a little cleanup ..."
rm -rf *.zip && ok_msg "Done!" && ok_msg "Fluidd installation complete!"
echo
}

246
scripts/install_klipper_webui.sh Executable file
View File

@@ -0,0 +1,246 @@
check_moonraker(){
status_msg "Checking for Moonraker service ..."
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "moonraker.service")" ]; then
ok_msg "Moonraker service found!"; echo
MOONRAKER_SERVICE_FOUND="true"
else
warn_msg "Moonraker service not found!"
warn_msg "Please install Moonraker first!"; echo
MOONRAKER_SERVICE_FOUND="false"
fi
}
get_user_selection_webui(){
#ask user for webui default macros
while true; do
unset ADD_WEBUI_MACROS
echo
top_border
echo -e "| It is recommended to have some important macros to |"
echo -e "| have full functionality of the web interface. |"
blank_line
echo -e "| If you do not have such macros, you can choose to |"
echo -e "| install the suggested default macros now. |"
bottom_border
read -p "${cyan}###### Add the recommended macros? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
echo -e "###### > Yes"
ADD_WEBUI_MACROS="true"
break;;
N|n|No|no)
echo -e "###### > No"
ADD_WEBUI_MACROS="false"
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
}
install_mainsail(){
get_user_selection_webui
#check if moonraker is already installed
check_moonraker
if [ "$MOONRAKER_SERVICE_FOUND" = "true" ]; then
#check for other enabled web interfaces
unset SET_LISTEN_PORT
detect_enabled_sites
#check if another site already listens to port 80
mainsail_port_check
#creating the mainsail nginx cfg
set_nginx_cfg "mainsail"
test_nginx "$SET_LISTEN_PORT"
locate_printer_cfg && read_printer_cfg "mainsail"
install_webui_macros
mainsail_setup
fi
}
install_fluidd(){
get_user_selection_webui
#check if moonraker is already installed
check_moonraker
if [ "$MOONRAKER_SERVICE_FOUND" = "true" ]; then
#check for other enabled web interfaces
unset SET_LISTEN_PORT
detect_enabled_sites
#check if another site already listens to port 80
fluidd_port_check
#creating the fluidd nginx cfg
set_nginx_cfg "fluidd"
test_nginx "$SET_LISTEN_PORT"
locate_printer_cfg && read_printer_cfg "fluidd"
install_webui_macros
fluidd_setup
fi
}
install_webui_macros(){
#copy webui_macros.cfg
if [ "$ADD_WEBUI_MACROS" = "true" ]; then
status_msg "Create webui_macros.cfg ..."
if [ ! -f ${HOME}/klipper_config/webui_macros.cfg ]; then
cp ${HOME}/kiauh/resources/webui_macros.cfg ${HOME}/klipper_config
ok_msg "File created!"
else
warn_msg "File already exists! Skipping ..."
fi
fi
write_printer_cfg
}
mainsail_port_check(){
if [ "$MAINSAIL_ENABLED" = "false" ]; then
if [ "$SITE_ENABLED" = "true" ]; then
status_msg "Detected other enabled interfaces:"
[ "$OCTOPRINT_ENABLED" = "true" ] && echo -e " ${cyan}● OctoPrint - Port: $OCTOPRINT_PORT${default}"
[ "$FLUIDD_ENABLED" = "true" ] && echo -e " ${cyan}● Fluidd - Port: $FLUIDD_PORT${default}"
[ "$DWC2_ENABLED" = "true" ] && echo -e " ${cyan}● DWC2 - Port: $DWC2_PORT${default}"
if [ "$FLUIDD_PORT" = "80" ] || [ "$DWC2_PORT" = "80" ] || [ "$OCTOPRINT_PORT" = "80" ]; then
PORT_80_BLOCKED="true"
select_mainsail_port
fi
else
DEFAULT_PORT=$(grep listen ${SRCDIR}/kiauh/resources/mainsail_nginx.cfg | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
SET_LISTEN_PORT=$DEFAULT_PORT
fi
SET_NGINX_CFG="true"
else
SET_NGINX_CFG="false"
fi
}
fluidd_port_check(){
if [ "$FLUIDD_ENABLED" = "false" ]; then
if [ "$SITE_ENABLED" = "true" ]; then
status_msg "Detected other enabled interfaces:"
[ "$OCTOPRINT_ENABLED" = "true" ] && echo " ${cyan}● OctoPrint - Port: $OCTOPRINT_PORT${default}"
[ "$MAINSAIL_ENABLED" = "true" ] && echo " ${cyan}● Mainsail - Port: $MAINSAIL_PORT${default}"
[ "$DWC2_ENABLED" = "true" ] && echo " ${cyan}● DWC2 - Port: $DWC2_PORT${default}"
if [ "$MAINSAIL_PORT" = "80" ] || [ "$DWC2_PORT" = "80" ] || [ "$OCTOPRINT_PORT" = "80" ]; then
PORT_80_BLOCKED="true"
select_fluidd_port
fi
else
DEFAULT_PORT=$(grep listen ${SRCDIR}/kiauh/resources/fluidd_nginx.cfg | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
SET_LISTEN_PORT=$DEFAULT_PORT
fi
SET_NGINX_CFG="true"
else
SET_NGINX_CFG="false"
fi
}
select_mainsail_port(){
if [ "$PORT_80_BLOCKED" = "true" ]; then
echo
top_border
echo -e "| ${red}!!!WARNING!!!${default} |"
echo -e "| ${red}You need to choose a different port for Mainsail!${default} |"
echo -e "| ${red}The following web interface is listening at port 80:${default} |"
blank_line
[ "$OCTOPRINT_PORT" = "80" ] && echo "| ● OctoPrint |"
[ "$FLUIDD_PORT" = "80" ] && echo "| ● Fluidd |"
[ "$DWC2_PORT" = "80" ] && echo "| ● DWC2 |"
blank_line
echo -e "| Make sure you don't choose a port which was already |"
echo -e "| assigned to one of the other web interfaces! |"
blank_line
echo -e "| Be aware: there is ${red}NO${default} sanity check for the following |"
echo -e "| input. So make sure to choose a valid port! |"
bottom_border
while true; do
read -p "${cyan}Please enter a new Port:${default} " NEW_PORT
if [ "$NEW_PORT" != "$FLUIDD_PORT" ] && [ "$NEW_PORT" != "$DWC2_PORT" ] && [ "$NEW_PORT" != "$OCTOPRINT_PORT" ]; then
echo "Setting port $NEW_PORT for Mainsail!"
SET_LISTEN_PORT=$NEW_PORT
break
else
echo "That port is already taken! Select a different one!"
fi
done
fi
}
select_fluidd_port(){
if [ "$PORT_80_BLOCKED" = "true" ]; then
echo
top_border
echo -e "| ${red}!!!WARNING!!!${default} |"
echo -e "| ${red}You need to choose a different port for Fluidd!${default} |"
echo -e "| ${red}The following web interface is listening at port 80:${default} |"
blank_line
[ "$OCTOPRINT_PORT" = "80" ] && echo "| ● OctoPrint |"
[ "$MAINSAIL_PORT" = "80" ] && echo "| ● Mainsail |"
[ "$DWC2_PORT" = "80" ] && echo "| ● DWC2 |"
blank_line
echo -e "| Make sure you don't choose a port which was already |"
echo -e "| assigned to one of the other web interfaces! |"
blank_line
echo -e "| Be aware: there is ${red}NO${default} sanity check for the following |"
echo -e "| input. So make sure to choose a valid port! |"
bottom_border
while true; do
read -p "${cyan}Please enter a new Port:${default} " NEW_PORT
if [ "$NEW_PORT" != "$MAINSAIL_PORT" ] && [ "$NEW_PORT" != "$DWC2_PORT" ] && [ "$NEW_PORT" != "$OCTOPRINT_PORT" ]; then
echo "Setting port $NEW_PORT for Fluidd!"
SET_LISTEN_PORT=$NEW_PORT
break
else
echo "That port is already taken! Select a different one!"
fi
done
fi
}
get_mainsail_ver(){
MAINSAIL_VERSION=$(curl -s https://api.github.com/repositories/240875926/releases | grep tag_name | cut -d'"' -f4 | cut -d"v" -f2 | head -1)
}
get_fluidd_ver(){
FLUIDD_VERSION=$(curl -s https://api.github.com/repositories/295836951/releases | grep tag_name | cut -d'"' -f4 | cut -d"v" -f2 | head -1)
}
mainsail_setup(){
#get mainsail download url
MAINSAIL_DL_URL=$(curl -s https://api.github.com/repositories/240875926/releases | grep browser_download_url | cut -d'"' -f4 | head -1)
#clean up an existing mainsail folder
[ -d $MAINSAIL_DIR ] && rm -rf $MAINSAIL_DIR
#create fresh mainsail folder and download mainsail
mkdir $MAINSAIL_DIR && cd $MAINSAIL_DIR
status_msg "Downloading Mainsail $MAINSAIL_VERSION ..."
wget $MAINSAIL_DL_URL && ok_msg "Download complete!"
#extract archive
status_msg "Extracting archive ..."
unzip -q -o *.zip && ok_msg "Done!"
### write mainsail version to file for update check reasons
status_msg "Writing Mainsail version to file ..."
get_mainsail_ver && echo "$MAINSAIL_VERSION" > $MAINSAIL_DIR/version && ok_msg "Done!"
#delete downloaded zip
status_msg "Remove downloaded archive ..."
rm -rf *.zip && ok_msg "Done!" && ok_msg "Mainsail installation complete!"
echo
}
fluidd_setup(){
#get fluidd download url
FLUIDD_DL_URL=$(curl -s https://api.github.com/repositories/295836951/releases/latest | grep browser_download_url | cut -d'"' -f4)
#clean up an existing fluidd folder
[ -d $FLUIDD_DIR ] && rm -rf $FLUIDD_DIR
#create fresh fluidd folder and download fluidd
mkdir $FLUIDD_DIR && cd $FLUIDD_DIR
status_msg "Downloading Fluidd $FLUIDD_VERSION ..."
wget $FLUIDD_DL_URL && ok_msg "Download complete!"
#extract archive
status_msg "Extracting archive ..."
unzip -q -o *.zip && ok_msg "Done!"
#write fluidd version to file for update check reasons
status_msg "Writing Fluidd version to file ..."
get_fluidd_ver && echo $FLUIDD_VERSION > $FLUIDD_DIR/version && ok_msg "Done!"
#delete downloaded zip
status_msg "Remove downloaded archive ..."
rm -rf *.zip && ok_msg "Done!" && ok_msg "Fluidd installation complete!"
echo
}

View File

@@ -1,103 +0,0 @@
install_mainsail(){
if [ "$INST_MAINSAIL" = "true" ]; then
#check if moonraker is already installed
check_moonraker
if [ "$MOONRAKER_SERVICE_FOUND" = "true" ]; then
#check for other enabled web interfaces
unset SET_LISTEN_PORT
detect_enabled_sites
#check if another site already listens to port 80
mainsail_port_check
#creating the mainsail nginx cfg
set_nginx_cfg "mainsail"
test_nginx "$SET_LISTEN_PORT"
mainsail_setup && ok_msg "Mainsail installation complete!"; echo
fi
fi
}
check_moonraker(){
status_msg "Checking for Moonraker service ..."
if [ "$(systemctl list-units --full -all -t service --no-legend | grep -F "moonraker.service")" ]; then
ok_msg "Moonraker service found!"; echo
MOONRAKER_SERVICE_FOUND="true"
else
warn_msg "Moonraker service not found!"
warn_msg "Please install Moonraker first!"; echo
MOONRAKER_SERVICE_FOUND="false"
fi
}
mainsail_port_check(){
if [ "$MAINSAIL_ENABLED" = "false" ]; then
if [ "$SITE_ENABLED" = "true" ]; then
status_msg "Detected other enabled interfaces:"
[ "$OCTOPRINT_ENABLED" = "true" ] && echo -e " ${cyan}● OctoPrint - Port: $OCTOPRINT_PORT${default}"
[ "$FLUIDD_ENABLED" = "true" ] && echo -e " ${cyan}● Fluidd - Port: $FLUIDD_PORT${default}"
[ "$DWC2_ENABLED" = "true" ] && echo -e " ${cyan}● DWC2 - Port: $DWC2_PORT${default}"
if [ "$FLUIDD_PORT" = "80" ] || [ "$DWC2_PORT" = "80" ] || [ "$OCTOPRINT_PORT" = "80" ]; then
PORT_80_BLOCKED="true"
select_mainsail_port
fi
else
DEFAULT_PORT=$(grep listen ${SRCDIR}/kiauh/resources/mainsail_nginx.cfg | head -1 | sed 's/^\s*//' | cut -d" " -f2 | cut -d";" -f1)
SET_LISTEN_PORT=$DEFAULT_PORT
fi
SET_NGINX_CFG="true"
else
SET_NGINX_CFG="false"
fi
}
select_mainsail_port(){
if [ "$PORT_80_BLOCKED" = "true" ]; then
echo
top_border
echo -e "| ${red}!!!WARNING!!!${default} |"
echo -e "| ${red}You need to choose a different port for Mainsail!${default} |"
echo -e "| ${red}The following web interface is listening at port 80:${default} |"
blank_line
[ "$OCTOPRINT_PORT" = "80" ] && echo "| ● OctoPrint |"
[ "$FLUIDD_PORT" = "80" ] && echo "| ● Fluidd |"
[ "$DWC2_PORT" = "80" ] && echo "| ● DWC2 |"
blank_line
echo -e "| Make sure you don't choose a port which was already |"
echo -e "| assigned to one of the other web interfaces! |"
blank_line
echo -e "| Be aware: there is ${red}NO${default} sanity check for the following |"
echo -e "| input. So make sure to choose a valid port! |"
bottom_border
while true; do
read -p "${cyan}Please enter a new Port:${default} " NEW_PORT
if [ "$NEW_PORT" != "$FLUIDD_PORT" ] && [ "$NEW_PORT" != "$DWC2_PORT" ] && [ "$NEW_PORT" != "$OCTOPRINT_PORT" ]; then
echo "Setting port $NEW_PORT for Mainsail!"
SET_LISTEN_PORT=$NEW_PORT
break
else
echo "That port is already taken! Select a different one!"
fi
done
fi
}
get_mainsail_ver(){
MAINSAIL_VERSION=$(curl -s https://api.github.com/repositories/240875926/tags | grep name | cut -d'"' -f4 | cut -d"v" -f2 | head -1)
}
mainsail_dl_url(){
get_mainsail_ver
MAINSAIL_URL=https://github.com/meteyou/mainsail/releases/download/v$MAINSAIL_VERSION/mainsail-beta-$MAINSAIL_VERSION.zip
}
mainsail_setup(){
mainsail_dl_url
#clean up an existing mainsail folder
[ -d $MAINSAIL_DIR ] && rm -rf $MAINSAIL_DIR
#create fresh mainsail folder and download mainsail
mkdir $MAINSAIL_DIR && cd $MAINSAIL_DIR
status_msg "Downloading Mainsail v$MAINSAIL_VERSION ..."
wget -O mainsail.zip $MAINSAIL_URL && status_msg "Extracting archive ..." && unzip -o mainsail.zip && rm mainsail.zip
### write mainsail version to file for update check reasons
echo "$MAINSAIL_VERSION" > $MAINSAIL_DIR/version
echo
}

View File

@@ -8,13 +8,12 @@ install_moonraker(){
moonraker_setup
check_for_folder_moonraker
#setup configs
setup_printer_config_mainsail
setup_printer_config_moonraker
setup_moonraker_conf
#execute customizations
write_custom_trusted_clients
symlinks_moonraker
disable_octoprint
set_hostname
#after install actions
restart_moonraker
restart_klipper
@@ -32,17 +31,9 @@ system_check_moonraker(){
PRINTER_CFG_FOUND="false"
fi
#check for existing klippy.log symlink in /klipper_config
if [ ! -e ${HOME}/klipper_config/klippy.log ]; then
KLIPPY_SL_FOUND="false"
else
KLIPPY_SL_FOUND="true"
fi
[ ! -e ${HOME}/klipper_config/klippy.log ] && KLIPPY_SL_FOUND="false"
#check for existing moonraker.log symlink in /klipper_config
if [ ! -e ${HOME}/klipper_config/moonraker.log ]; then
MOONRAKER_SL_FOUND="false"
else
MOONRAKER_SL_FOUND="true"
fi
[ ! -e ${HOME}/klipper_config/moonraker.log ] && MOONRAKER_SL_FOUND="false"
#check for existing moonraker.conf
if [ ! -f ${HOME}/moonraker.conf ]; then
MOONRAKER_CONF_FOUND="false"
@@ -55,13 +46,9 @@ system_check_moonraker(){
OCTOPRINT_ENABLED="true"
fi
#check if haproxy is installed
if [[ $(dpkg-query -f'${Status}' --show haproxy 2>/dev/null) = *\ installed ]]; then
HAPROXY_FOUND="true"
fi
[[ $(dpkg-query -f'${Status}' --show haproxy 2>/dev/null) = *\ installed ]] && HAPROXY_FOUND="true"
#check if lighttpd is installed
if [[ $(dpkg-query -f'${Status}' --show lighttpd 2>/dev/null) = *\ installed ]]; then
LIGHTTPD_FOUND="true"
fi
[[ $(dpkg-query -f'${Status}' --show lighttpd 2>/dev/null) = *\ installed ]] && LIGHTTPD_FOUND="true"
}
get_user_selections_moonraker(){
@@ -158,25 +145,6 @@ get_user_selections_moonraker(){
print_msg && clear_msg;;
esac
done
#ask user for mainsail default macros
while true; do
unset ADD_MS_MACROS
echo
read -p "${cyan}###### Add the recommended Mainsail macros? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
echo -e "###### > Yes"
ADD_MS_MACROS="true"
break;;
N|n|No|no)
echo -e "###### > No"
ADD_MS_MACROS="false"
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
done
#ask user to disable octoprint when such installed service was found
if [ "$OCTOPRINT_ENABLED" = "true" ]; then
unset DISABLE_OPRINT
@@ -274,9 +242,6 @@ moonraker_setup(){
dep=(wget curl unzip dfu-util nginx)
dependency_check
status_msg "Downloading Moonraker ..."
if [ -d $MOONRAKER_DIR ]; then
mv -f $MOONRAKER_DIR ${HOME}/moonraker_bak
fi
cd ${HOME} && git clone $MOONRAKER_REPO
ok_msg "Download complete!"
status_msg "Installing Moonraker ..."
@@ -354,7 +319,7 @@ check_for_folder_moonraker(){
#############################################################
#############################################################
setup_printer_config_mainsail(){
setup_printer_config_moonraker(){
if [ "$PRINTER_CFG_FOUND" = "true" ]; then
backup_printer_cfg
#copy printer.cfg to new location if
@@ -365,34 +330,20 @@ setup_printer_config_mainsail(){
ok_msg "printer.cfg location: '$PRINTER_CFG'"
ok_msg "Done!"
fi
#check printer.cfg for necessary mainsail entries
read_printer_cfg_mainsail
write_printer_cfg_mainsail
#check printer.cfg for necessary moonraker entries
read_printer_cfg "moonraker"
write_printer_cfg
fi
if [ "$SEL_DEF_CFG" = "true" ]; then
status_msg "Creating minimal default printer.cfg ..."
create_default_mainsail_printer_cfg
create_default_moonraker_printer_cfg
ok_msg "printer.cfg location: '$PRINTER_CFG'"
ok_msg "Done!"
fi
#copy mainsail_macro.cfg
if [ "$ADD_MS_MACROS" = "true" ]; then
status_msg "Create mainsail_macros.cfg ..."
if [ ! -f ${HOME}/klipper_config/mainsail_macros.cfg ]; then
cp ${HOME}/kiauh/resources/mainsail_macros.cfg ${HOME}/klipper_config
ok_msg "File created!"
else
warn_msg "File does already exist! Skipping ..."
fi
fi
}
read_printer_cfg_mainsail(){
sc_check(){
SC="#*# <---------------------- SAVE_CONFIG ---------------------->"
[ ! "$(grep '^\[virtual_sdcard\]$' $PRINTER_CFG)" ] && VSD="false"
[ ! "$(grep '^\[pause_resume\]$' $PRINTER_CFG)" ] && PAUSE_RESUME="false"
[ ! "$(grep '^\[display_status\]$' $PRINTER_CFG)" ] && DISPLAY_STATUS="false"
[ ! "$(grep '^\[include mainsail_macros\.cfg\]$' $PRINTER_CFG)" ] && MS_MACRO="false"
#check for a SAVE_CONFIG entry
if [[ $(grep "$SC" $PRINTER_CFG) ]]; then
SC_LINE=$(grep -n "$SC" $PRINTER_CFG | cut -d ":" -f1)
@@ -403,39 +354,39 @@ read_printer_cfg_mainsail(){
fi
}
write_printer_cfg_mainsail(){
read_printer_cfg(){
echo "selected: $1"
echo "pre sc"
sc_check
echo "past sc"
if [ "$1" = "moonraker" ]; then
echo "$1" && echo "moonraker"
[ ! "$(grep '^\[virtual_sdcard\]$' $PRINTER_CFG)" ] && VSD="false"
[ ! "$(grep '^\[pause_resume\]$' $PRINTER_CFG)" ] && PAUSE_RESUME="false"
[ ! "$(grep '^\[display_status\]$' $PRINTER_CFG)" ] && DISPLAY_STATUS="false"
elif [ "$1" = "mainsail" ] || [ "$1" = "fluidd" ]; then
echo "$1" && echo "mainsail/fluidd"
[ ! "$(grep '^\[include webui_macros\.cfg\]$' $PRINTER_CFG)" ] && WEBUI_MACROS="false"
fi
}
write_printer_cfg(){
unset write_entries
if [ "$MS_MACRO" = "false" ] && [ "$ADD_MS_MACROS" = "true" ]; then
write_entries+=("[include mainsail_macros.cfg]")
fi
if [ "$PAUSE_RESUME" = "false" ]; then
write_entries+=("[pause_resume]")
fi
if [ "$DISPLAY_STATUS" = "false" ]; then
write_entries+=("[display_status]")
fi
if [ "$VSD" = "false" ]; then
write_entries+=("[virtual_sdcard]\npath: ~/sdcard")
fi
if [ "${#write_entries[@]}" != "0" ]; then
write_entries+=("\\\n############################\n##### CREATED BY KIAUH #####\n############################")
write_entries=("############################\n" "${write_entries[@]}")
fi
#execute writing
status_msg "Writing to printer.cfg ..."
if [ "$SC_ENTRY" = "true" ]; then
PRE_SC_LINE="$(expr $SC_LINE - 1)a"
for entry in "${write_entries[@]}"
do
sed -i "$PRE_SC_LINE $entry" $PRINTER_CFG
done
fi
if [ "$SC_ENTRY" = "false" ]; then
LINE_COUNT="$(wc -l < $PRINTER_CFG)a"
for entry in "${write_entries[@]}"
do
sed -i "$LINE_COUNT $entry" $PRINTER_CFG
done
[ "$VSD" = "false" ] && write_entries+=("[virtual_sdcard]\npath: ~/sdcard")
[ "$PAUSE_RESUME" = "false" ] && write_entries+=("[pause_resume]")
[ "$DISPLAY_STATUS" = "false" ] && write_entries+=("[display_status]")
[ "$WEBUI_MACROS" = "false" ] && [ "$ADD_WEBUI_MACROS" = "true" ] && write_entries+=("[include webui_macros.cfg]")
[ "${#write_entries[@]}" != "0" ] && write_entries=("##### AUTOCREATED BY KIAUH #####" "${write_entries[@]}")
#write needed entries to kiauh.cfg
for entry in "${write_entries[@]}"; do echo -e "$entry" >> ~/klipper_config/kiauh.cfg; done
#execute writing to printer.cfg
if [ ! "$(grep '^\[include kiauh\.cfg\]$' $PRINTER_CFG)" ]; then
status_msg "Writing [include kiauh.cfg] to printer.cfg ..."
[ "$SC_ENTRY" = "false" ] && echo -e "\n\n[include kiauh.cfg]\c" >> $PRINTER_CFG
if [ "$SC_ENTRY" = "true" ]; then
PRE_SC_LINE="$(expr $SC_LINE - 1)a"
sed -i "$PRE_SC_LINE [include kiauh.cfg]" $PRINTER_CFG
fi
fi
ok_msg "Done!"
}
@@ -479,23 +430,16 @@ setup_moonraker_nginx_cfg(){
#############################################################
#############################################################
create_default_mainsail_printer_cfg(){
create_default_moonraker_printer_cfg(){
#create default config
touch ${HOME}/klipper_config/printer.cfg
cat <<DEFAULT_CFG >> ${HOME}/klipper_config/printer.cfg
##########################
### CREATED WITH KIAUH ###
##########################
### AUTOCREATED WITH KIAUH ###
[virtual_sdcard]
path: ~/sdcard
[pause_resume]
[display_status]
[include mainsail_macros.cfg]
##########################
##########################
DEFAULT_CFG
}

View File

@@ -41,13 +41,13 @@ install_menu(){
4)
clear
print_header
INST_MAINSAIL="true" && install_mainsail
install_mainsail
print_msg && clear_msg
install_ui;;
5)
clear
print_header
INST_FLUIDD="true" && install_fluidd
install_fluidd
print_msg && clear_msg
install_ui;;
6)