From 96be30343d0db5d1284cc2dd39fba95df472c4fd Mon Sep 17 00:00:00 2001 From: th33xitus <> Date: Sun, 30 Aug 2020 13:35:14 +0200 Subject: [PATCH 1/8] fix: rework klipper installation routine --- scripts/functions.sh | 111 ------------------ scripts/install_klipper.sh | 223 ++++++++++++++++++++++++++++++++---- scripts/ui/advanced_menu.sh | 10 +- 3 files changed, 210 insertions(+), 134 deletions(-) diff --git a/scripts/functions.sh b/scripts/functions.sh index f21f922..692a95c 100755 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -187,117 +187,6 @@ print_error(){ fi } -build_fw(){ - if [ -d $KLIPPER_DIR ]; then - cd $KLIPPER_DIR && make menuconfig - status_msg "Building Firmware ..." - make clean && make && ok_msg "Firmware built!" - else - warn_msg "Can not build Firmware without a Klipper directory!" - fi -} - -### grab the printers id -get_printer_usb(){ - warn_msg "Make sure your printer is the only USB device connected!" - while true; do - echo -e "${cyan}" - read -p "###### Press any key to continue ... " yn - echo -e "${default}" - case "$yn" in - *) break;; - esac - done - status_msg "Identifying the correct USB port ..." - sleep 3 - if [ -e /dev/serial/by-id/* ]; then - if [ -e /dev/serial/by-id/* ]; then - PRINTER_USB=$(ls /dev/serial/by-id/*) - status_msg "The ID of your printer is:" - title_msg "$PRINTER_USB" - echo - else - warn_msg "Could not retrieve ID!" - echo - fi - elif [ -e /dev/serial/by-path/* ]; then - if [ -e /dev/serial/by-path/* ]; then - PRINTER_USB=$(ls /dev/serial/by-path/*) - status_msg "The path of your printer is:" - title_msg "$PRINTER_USB" - echo - else - warn_msg "Could not retrieve path!" - echo - fi - else - warn_msg "Printer not plugged in or not detectable!" - echo -fi -} - -write_printer_usb(){ - while true; do - echo -e "${cyan}" - read -p "###### Do you want to write the ID to your printer.cfg? (Y/n): " yn - echo -e "${default}" - case "$yn" in - Y|y|Yes|yes|"") - backup_printer_cfg -cat <> $PRINTER_CFG - -########################## -### CREATED WITH KIAUH ### -########################## -[mcu] -serial: $PRINTER_USB -########################## -########################## -PRINTERUSB - echo - ok_msg "Config written!" - break;; - N|n|No|no) break;; - esac - done -} - -flash_routine(){ - echo -e "/=================================================\ " - echo -e "| ${red}~~~~~~~~~~~ [ ATTENTION! ] ~~~~~~~~~~~~${default} |" - echo -e "| Flashing a Smoothie based board for the first |" - echo -e "| time with this script will certainly fail. |" - echo -e "| This applies to boards like the BTT SKR V1.3 or |" - echo -e "| the newer SKR V1.4 (Turbo). You have to copy |" - echo -e "| the firmware file to the microSD card manually |" - echo -e "| and rename it to 'firmware.bin'. |" - echo -e "| |" - echo -e "| You find the file in: ~/klipper/out/klipper.bin |" - echo -e "\=================================================/ " - echo - while true; do - echo -e "${cyan}" - read -p "###### Do you want to continue? (Y/n): " yn - echo -e "${default}" - case "$yn" in - Y|y|Yes|yes|"") - get_printer_usb && flash_mcu && write_printer_usb; break;; - N|n|No|no) break;; - esac - done -} - -flash_mcu(){ - stop_klipper - if ! make flash FLASH_DEVICE="$PRINTER_USB" ; then - warn_msg "Flashing failed!" - warn_msg "Please read the log above!" - else - ok_msg "Flashing successfull!" - fi - start_klipper -} - remove_branding(){ echo top_border diff --git a/scripts/install_klipper.sh b/scripts/install_klipper.sh index 76619bb..b693e10 100755 --- a/scripts/install_klipper.sh +++ b/scripts/install_klipper.sh @@ -1,29 +1,210 @@ install_klipper(){ if [ -e /etc/init.d/klipper ] && [ -e /etc/default/klipper ]; then - ERROR_MSG=" Looks like Klipper is already installed!\n Skipping ..." + ERROR_MSG="Looks like Klipper is already installed!" else - #check for dependencies - dep=(git) - dependency_check - #execute operation - cd ${HOME} - status_msg "Cloning Klipper repository ..." - git clone $KLIPPER_REPO && ok_msg "Klipper successfully cloned!" - status_msg "Installing Klipper Service ..." - $KLIPPER_DIR/scripts/install-octopi.sh && sleep 2 && ok_msg "Klipper installation complete!" - #create a klippy.log symlink in home-dir just for convenience - if [ ! -e ${HOME}/klippy.log ]; then - status_msg "Creating klippy.log Symlink ..." - ln -s /tmp/klippy.log ${HOME}/klippy.log && ok_msg "Symlink created!" - fi - while true; do - echo -e "${cyan}" - read -p "###### Do you want to flash your MCU now? (Y/n): " yn - echo -e "${default}" + get_user_selections_klipper + klipper_setup + build_fw + flash_mcu + write_printer_usb + fi +} + +get_user_selections_klipper(){ + status_msg "Initializing Klipper installation ..." + #ask user for building firmware + while true; do + echo + read -p "${cyan}###### Do you want to build the Firmware? (Y/n):${default} " yn case "$yn" in - Y|y|Yes|yes|"") build_fw && flash_routine; break;; - N|n|No|no) break;; + Y|y|Yes|yes|"") + echo -e "###### > Yes" + BUILD_FIRMWARE="true" + break;; + N|n|No|no) + echo -e "###### > No" + BUILD_FIRMWARE="false" + break;; esac done + #ask user for flashing mcu + while true; do + echo + read -p "${cyan}###### Do you want to flash your MCU? (Y/n):${default} " yn + case "$yn" in + Y|y|Yes|yes|"") + echo -e "###### > Yes" + FLASH_FIRMWARE="true" + flash_routine + break;; + N|n|No|no) + echo -e "###### > No" + FLASH_FIRMWARE="false" + break;; + esac + done +} + +klipper_setup(){ + #check for dependencies + dep=(git) + dependency_check + #execute operation + cd ${HOME} + status_msg "Cloning Klipper repository ..." + git clone $KLIPPER_REPO + ok_msg "Klipper successfully cloned!" + status_msg "Installing Klipper Service ..." + $KLIPPER_DIR/scripts/install-octopi.sh + ok_msg "Klipper installation complete!" + #create a klippy.log symlink in home-dir just for convenience + if [ ! -e ${HOME}/klippy.log ]; then + status_msg "Creating klippy.log Symlink ..." + ln -s /tmp/klippy.log ${HOME}/klippy.log + ok_msg "Symlink created!" + fi +} + +flash_routine(){ + if [ "$FLASH_FIRMWARE" = "true" ]; then + echo + top_border + echo -e "| ${red}~~~~~~~~~~~ [ ATTENTION! ] ~~~~~~~~~~~~${default} |" + hr + echo -e "| Flashing a Smoothie based board with this script will |" + echo -e "| certainly fail. This applies to boards like the BTT |" + echo -e "| SKR V1.3 or SKR V1.4(Turbo). You have to copy the |" + echo -e "| firmware file to the microSD card manually and rename |" + echo -e "| it to 'firmware.bin'. |" + hr + echo -e "| You can find the file in: ~/klipper/out/klipper.bin |" + bottom_border + while true; do + read -p "${cyan}###### Do you want to continue? (Y/n):${default} " yn + case "$yn" in + Y|y|Yes|yes|"") + echo -e "###### > Yes" + CONFIRM_FLASHING="true" + CONFIRM_WRITE_PRINTER_USB="true" + get_printer_usb + break;; + N|n|No|no) + echo -e "###### > No" + CONFIRM_FLASHING="false" + CONFIRM_WRITE_PRINTER_USB="false" + break;; + esac + done + fi +} + +flash_mcu(){ + if [ "$CONFIRM_FLASHING" = "true" ] && [ ! -z "$PRINTER_USB" ]; then + stop_klipper + if ! make flash FLASH_DEVICE="$PRINTER_USB" ; then + warn_msg "Flashing failed!" + warn_msg "Please read the console output above!" + else + ok_msg "Flashing successfull!" + fi + start_klipper + fi +} + +build_fw(){ + if [ "$BUILD_FIRMWARE" = "true" ]; then + if [ -d $KLIPPER_DIR ]; then + cd $KLIPPER_DIR + status_msg "Initializing Firmware Setup ..." + make menuconfig + status_msg "Building Firmware ..." + make clean && make && ok_msg "Firmware built!" + else + warn_msg "Can not build Firmware without a Klipper directory!" + fi + fi +} + +### grab the printers id +get_printer_usb(){ + echo + top_border + echo -e "| Please make sure your printer is connected to the Pi! |" + echo -e "| If the printer is not connected yet, connect it now. |" + hr + echo -e "| Also make sure, that it is the only USB device |" + echo -e "| connected at for now! Otherwise this step may fail! |" + bottom_border + while true; do + echo -e "${cyan}" + read -p "###### Press any key to continue ... " yn + echo -e "${default}" + case "$yn" in + *) + CONFIRM_PRINTER_USB="true" + break;; + esac + done + status_msg "Identifying the correct USB port ..." + sleep 2 + unset PRINTER_USB + if [ -e /dev/serial/by-id/* ]; then + if [ -e /dev/serial/by-id/* ]; then + PRINTER_USB=$(ls /dev/serial/by-id/*) + status_msg "The ID of your printer is:" + title_msg "$PRINTER_USB" + else + warn_msg "Could not retrieve ID!" + fi + elif [ -e /dev/serial/by-path/* ]; then + if [ -e /dev/serial/by-path/* ]; then + PRINTER_USB=$(ls /dev/serial/by-path/*) + status_msg "The path of your printer is:" + title_msg "$PRINTER_USB" + else + warn_msg "Could not retrieve path!" + fi + else + warn_msg "Printer not plugged in or not detectable!" +fi +} + +write_printer_usb(){ + locate_printer_cfg + if [ ! -z "$PRINTER_CFG" ] && [ "$CONFIRM_WRITE_PRINTER_USB" = "true" ]; then + SERIAL_OLD=$(grep "serial" $PRINTER_CFG | tail -1 | cut -d" " -f2) + SERIAL_NEW=$PRINTER_USB + if [ "$SERIAL_OLD" != "$SERIAL_NEW" ]; then + unset write_entries + backup_printer_cfg + write_entries+=("[mcu]\nserial: $SERIAL_NEW") + write_entries+=("\\\n############################\n##### CREATED BY KIAUH #####\n############################") + write_entries=("############################\n" "${write_entries[@]}") + #check for a SAVE_CONFIG entry + SC="#*# <---------------------- SAVE_CONFIG ---------------------->" + if [[ $(grep "$SC" $PRINTER_CFG) ]]; then + SC_LINE=$(grep -n "$SC" $PRINTER_CFG | cut -d ":" -f1) + PRE_SC_LINE=$(expr $SC_LINE - 1) + SC_ENTRY="true" + else + SC_ENTRY="false" + fi + status_msg "Writing printer ID/path 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 + fi + ok_msg "Done!" + fi fi } \ No newline at end of file diff --git a/scripts/ui/advanced_menu.sh b/scripts/ui/advanced_menu.sh index 9508328..3381273 100755 --- a/scripts/ui/advanced_menu.sh +++ b/scripts/ui/advanced_menu.sh @@ -10,8 +10,8 @@ advanced_ui(){ echo -e "| 2) [Rollback] | | " echo -e "| | Mainsail: | " echo -e "| Firmware: | 9) [Remove branding] | " - echo -e "| 3) [Build Firmware] | | " - echo -e "| 4) [Flash MCU] | Extensions: | " + echo -e "| 3) [Build only] | | " + echo -e "| 4) [Build + Flash MCU] | Extensions: | " echo -e "| 5) [Get Printer-USB] | 10) [Shell Command] | " echo -e "| 6) [Write Printer-USB] | | " echo -e "| 7) [Write DWC2 config] | | " @@ -51,13 +51,19 @@ advanced_menu(){ 3) clear print_header + unset BUILD_FIRMWARE && BUILD_FIRMWARE="true" build_fw print_msg && clear_msg advanced_ui;; 4) clear print_header + unset FLASH_FIRMWARE && FLASH_FIRMWARE="true" flash_routine + unset BUILD_FIRMWARE && BUILD_FIRMWARE="true" + build_fw + unset CONFIRM_FLASHING && CONFIRM_FLASHING="true" + flash_mcu print_msg && clear_msg advanced_ui;; 5) From fc777ccb964933e2597500a95913c8e246809b0a Mon Sep 17 00:00:00 2001 From: th33xitus <> Date: Sun, 30 Aug 2020 13:37:49 +0200 Subject: [PATCH 2/8] fix: remove two menu entries --- scripts/ui/advanced_menu.sh | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/scripts/ui/advanced_menu.sh b/scripts/ui/advanced_menu.sh index 3381273..2e92b71 100755 --- a/scripts/ui/advanced_menu.sh +++ b/scripts/ui/advanced_menu.sh @@ -6,15 +6,13 @@ advanced_ui(){ hr echo -e "| | | " echo -e "| Klipper: | System: | " - echo -e "| 1) [Switch Version] | 8) [Change hostname] | " + echo -e "| 1) [Switch Version] | 6) [Change hostname] | " echo -e "| 2) [Rollback] | | " echo -e "| | Mainsail: | " - echo -e "| Firmware: | 9) [Remove branding] | " + echo -e "| Firmware: | 7) [Remove branding] | " echo -e "| 3) [Build only] | | " echo -e "| 4) [Build + Flash MCU] | Extensions: | " - echo -e "| 5) [Get Printer-USB] | 10) [Shell Command] | " - echo -e "| 6) [Write Printer-USB] | | " - echo -e "| 7) [Write DWC2 config] | | " + echo -e "| 5) [Get Printer-USB] | 8) [Shell Command] | " echo -e "| | | " quit_footer } @@ -75,28 +73,16 @@ advanced_menu(){ 6) clear print_header - get_printer_usb && write_printer_usb + create_custom_hostname print_msg && clear_msg advanced_ui;; 7) - clear - print_header - create_dwc2fk_cfg - print_msg && clear_msg - advanced_ui;; - 8) - clear - print_header - create_custom_hostname - print_msg && clear_msg - advanced_ui;; - 9) clear print_header remove_branding print_msg && clear_msg advanced_ui;; - 10) + 8) clear print_header install_extension_shell_command From bae0c1f0fd49a7a19c9c61e09b7723ad0aa2a600 Mon Sep 17 00:00:00 2001 From: th33xitus <> Date: Sun, 30 Aug 2020 13:59:19 +0200 Subject: [PATCH 3/8] fix: typo and bug, also bring code in place for later moonraker version --- scripts/install_moonraker.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/scripts/install_moonraker.sh b/scripts/install_moonraker.sh index 2e7743c..aed627a 100755 --- a/scripts/install_moonraker.sh +++ b/scripts/install_moonraker.sh @@ -162,15 +162,16 @@ get_user_selections_moonraker(){ 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} " + read -p "${cyan}###### Add the recommended Mainsail macros? (Y/n):${default} " yn case "$yn" in Y|y|Yes|yes|"") echo -e "###### > Yes" - ADD_MS_MCAROS="true";; + ADD_MS_MACROS="true";; N|n|No|no) echo -e "###### > No" - ADD_MS_MCAROS="false";; + ADD_MS_MACROS="false";; esac break done @@ -212,6 +213,12 @@ moonraker_setup(){ ok_msg "Download complete!" status_msg "Installing Moonraker ..." $MOONRAKER_DIR/scripts/install-moonraker.sh + #if [[ ! $(grep "klippy_uds" $KLIPPER_SERVICE2) ]]; then + # status_msg "Patching /etc/default/klipper ..." + # sudo sed -i "/KLIPPY_ARGS/s/\.log/\.log -a \/tmp\/klippy_uds/" $KLIPPER_SERVICE2 + # ok_msg "Patching done!" + #fi + echo ok_msg "Moonraker successfully installed!" } @@ -255,7 +262,7 @@ setup_printer_config_mainsail(){ ok_msg "Done!" fi #copy mainsail_macro.cfg - if [ "$ADD_MS_MCAROS" = "true" ]; then + 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 @@ -292,7 +299,7 @@ read_printer_cfg_mainsail(){ write_printer_cfg_mainsail(){ unset write_entries - if [ "$MS_MACRO" = "false" ] && [ "$ADD_MS_MCAROS" = "true" ]; then + if [ "$MS_MACRO" = "false" ] && [ "$ADD_MS_MACROS" = "true" ]; then write_entries+=("[include klipper_config/mainsail_macros.cfg]") fi if [ "$PAUSE_RESUME" = "false" ]; then From 9ec63be67330d7b5fd21e2632e580fe099718df3 Mon Sep 17 00:00:00 2001 From: th33xitus <> Date: Tue, 1 Sep 2020 13:51:51 +0200 Subject: [PATCH 4/8] fix: rework locate_printer_cfg function --- scripts/functions.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/functions.sh b/scripts/functions.sh index 692a95c..d04b4ea 100755 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -12,16 +12,18 @@ check_euid(){ } locate_printer_cfg(){ + unset PRINTER_CFG + status_msg "Locating printer.cfg" if [ -f $KLIPPER_SERVICE2 ]; then #reads /etc/default/klipper and gets the default printer.cfg location - PRINTER_CFG_LOC=$(grep "KLIPPY_ARGS=" /etc/default/klipper | cut -d" " -f2) - if [ -e $PRINTER_CFG_LOC ]; then - PRINTER_CFG=$(readlink -e $PRINTER_CFG_LOC) - else - PRINTER_CFG="" - fi + KLIPPY_ARGS_LINE="$(grep "KLIPPY_ARGS=" /etc/default/klipper)" + KLIPPY_ARGS_COUNT="$(grep -o " " <<< "$KLIPPY_ARGS_LINE" | wc -l)" + i=1 + PRINTER_CFG=$(while [ "$i" != "$KLIPPY_ARGS_COUNT" ]; do grep -E "(\/[A-Za-z0-9\_-]+)+\/printer\.cfg" /etc/default/klipper | cut -d" " -f"$i"; i=$(( $i + 1 )); done | grep "printer.cfg") + ok_msg "printer.cfg found in: '$PRINTER_CFG'" else PRINTER_CFG="" + warn_msg "Couldn't locate printer.cfg - File not found!" fi } From 8a5e358a7319c84924ef0cadf4cb8c8641db5a91 Mon Sep 17 00:00:00 2001 From: th33xitus <> Date: Tue, 1 Sep 2020 13:52:36 +0200 Subject: [PATCH 5/8] fix: remove use of symlinks, also update for mainsail v0.2.0 --- scripts/install_moonraker.sh | 43 +++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/scripts/install_moonraker.sh b/scripts/install_moonraker.sh index aed627a..9383fce 100755 --- a/scripts/install_moonraker.sh +++ b/scripts/install_moonraker.sh @@ -213,11 +213,24 @@ moonraker_setup(){ ok_msg "Download complete!" status_msg "Installing Moonraker ..." $MOONRAKER_DIR/scripts/install-moonraker.sh - #if [[ ! $(grep "klippy_uds" $KLIPPER_SERVICE2) ]]; then - # status_msg "Patching /etc/default/klipper ..." - # sudo sed -i "/KLIPPY_ARGS/s/\.log/\.log -a \/tmp\/klippy_uds/" $KLIPPER_SERVICE2 - # ok_msg "Patching done!" - #fi + #backup a possible existing printer.cfg at the old location + #and before patching in the new location + backup_printer_cfg + #patching new printer.cfg location to /etc/default/klipper + if ! grep "/klipper_config/printer.cfg" $KLIPPER_SERVICE2; then + status_msg "Patching new printer.cfg location to /etc/default/klipper ..." + sudo sed -i "/KLIPPY_ARGS=/ s|$PRINTER_CFG|/home/${USER}/klipper_config/printer.cfg|" /etc/default/klipper + ok_msg "New location is: '/home/${USER}/klipper_config/printer.cfg'" + fi + #patching new UDS argument to /etc/default/klipper + if ! grep -- "-a /tmp/klippy_uds" $KLIPPER_SERVICE2; then + status_msg "Patching unix domain socket to /etc/default/klipper ..." + #append the new argument to /tmp/klippy.log argument + sudo sed -i "/KLIPPY_ARGS/s/\.log/\.log -a \/tmp\/klippy_uds/" $KLIPPER_SERVICE2 + ok_msg "Patching done!" + fi + #re-run printer.cfg location function to read the new path for the printer.cfg + locate_printer_cfg echo ok_msg "Moonraker successfully installed!" } @@ -243,12 +256,12 @@ check_for_folder_moonraker(){ setup_printer_config_mainsail(){ if [ "$PRINTER_CFG_FOUND" = "true" ]; then backup_printer_cfg - #create a printer.cfg symlink to make it accessible - #in the mainsail config editor if the printer.cfg is not - #located in klipper_config by default - if [ "$PRINTER_CFG" != "${HOME}/klipper_config/printer.cfg" ] && [ ! -f ${HOME}/klipper_config/printer.cfg ]; then - status_msg "Create printer.cfg symlink ..." - ln -s $PRINTER_CFG ${HOME}/klipper_config + #copy printer.cfg to new location if + #there is no printer.cfg at the new location already + if [ -f ${HOME}/printer.cfg ] && [ ! -f ${HOME}/klipper_config/printer.cfg ]; then + status_msg "Copy printer.cfg to new location ..." + cp ${HOME}/printer.cfg $PRINTER_CFG + ok_msg "printer.cfg location: '$PRINTER_CFG'" ok_msg "Done!" fi #check printer.cfg for necessary mainsail entries @@ -256,9 +269,9 @@ setup_printer_config_mainsail(){ write_printer_cfg_mainsail fi if [ "$SEL_DEF_CFG" = "true" ]; then + status_msg "Creating minimal default printer.cfg ..." create_default_mainsail_printer_cfg - status_msg "Create symlink in home directory ..." - ln -s ${HOME}/klipper_config/printer.cfg ${HOME} + ok_msg "printer.cfg location: '$PRINTER_CFG'" ok_msg "Done!" fi #copy mainsail_macro.cfg @@ -284,7 +297,7 @@ read_printer_cfg_mainsail(){ if [ ! $(grep '^\[display_status\]$' $PRINTER_CFG) ]; then DISPLAY_STATUS="false" fi - if [ ! "$(grep '^\[include klipper_config\/mainsail_macros\.cfg\]$' $PRINTER_CFG)" ]; then + if [ ! "$(grep '^\[include mainsail_macros\.cfg\]$' $PRINTER_CFG)" ]; then MS_MACRO="false" fi #check for a SAVE_CONFIG entry @@ -300,7 +313,7 @@ read_printer_cfg_mainsail(){ write_printer_cfg_mainsail(){ unset write_entries if [ "$MS_MACRO" = "false" ] && [ "$ADD_MS_MACROS" = "true" ]; then - write_entries+=("[include klipper_config/mainsail_macros.cfg]") + write_entries+=("[include mainsail_macros.cfg]") fi if [ "$PAUSE_RESUME" = "false" ]; then write_entries+=("[pause_resume]") From 49a28cff225e50c4e20f4adf33a4e97959e8b3f7 Mon Sep 17 00:00:00 2001 From: th33xitus <> Date: Tue, 1 Sep 2020 14:19:36 +0200 Subject: [PATCH 6/8] fix: better suited status message --- scripts/functions.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/functions.sh b/scripts/functions.sh index d04b4ea..05735b0 100755 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -13,14 +13,14 @@ check_euid(){ locate_printer_cfg(){ unset PRINTER_CFG - status_msg "Locating printer.cfg" + status_msg "Locating printer.cfg via /etc/default/klipper ..." if [ -f $KLIPPER_SERVICE2 ]; then #reads /etc/default/klipper and gets the default printer.cfg location KLIPPY_ARGS_LINE="$(grep "KLIPPY_ARGS=" /etc/default/klipper)" KLIPPY_ARGS_COUNT="$(grep -o " " <<< "$KLIPPY_ARGS_LINE" | wc -l)" i=1 PRINTER_CFG=$(while [ "$i" != "$KLIPPY_ARGS_COUNT" ]; do grep -E "(\/[A-Za-z0-9\_-]+)+\/printer\.cfg" /etc/default/klipper | cut -d" " -f"$i"; i=$(( $i + 1 )); done | grep "printer.cfg") - ok_msg "printer.cfg found in: '$PRINTER_CFG'" + ok_msg "printer.cfg location: '$PRINTER_CFG'" else PRINTER_CFG="" warn_msg "Couldn't locate printer.cfg - File not found!" From d9645235582b016f70041c759b46f970288813e6 Mon Sep 17 00:00:00 2001 From: th33xitus <> Date: Tue, 1 Sep 2020 14:22:28 +0200 Subject: [PATCH 7/8] fix: make some output silent --- scripts/install_moonraker.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install_moonraker.sh b/scripts/install_moonraker.sh index 9383fce..6457c82 100755 --- a/scripts/install_moonraker.sh +++ b/scripts/install_moonraker.sh @@ -217,13 +217,13 @@ moonraker_setup(){ #and before patching in the new location backup_printer_cfg #patching new printer.cfg location to /etc/default/klipper - if ! grep "/klipper_config/printer.cfg" $KLIPPER_SERVICE2; then + if ! grep -q "/klipper_config/printer.cfg" $KLIPPER_SERVICE2; then status_msg "Patching new printer.cfg location to /etc/default/klipper ..." sudo sed -i "/KLIPPY_ARGS=/ s|$PRINTER_CFG|/home/${USER}/klipper_config/printer.cfg|" /etc/default/klipper ok_msg "New location is: '/home/${USER}/klipper_config/printer.cfg'" fi #patching new UDS argument to /etc/default/klipper - if ! grep -- "-a /tmp/klippy_uds" $KLIPPER_SERVICE2; then + if ! grep -q -- "-a /tmp/klippy_uds" $KLIPPER_SERVICE2; then status_msg "Patching unix domain socket to /etc/default/klipper ..." #append the new argument to /tmp/klippy.log argument sudo sed -i "/KLIPPY_ARGS/s/\.log/\.log -a \/tmp\/klippy_uds/" $KLIPPER_SERVICE2 From 4a60b9c8ecc974bb86187a3e6f80150e67378e8f Mon Sep 17 00:00:00 2001 From: th33xitus <> Date: Tue, 1 Sep 2020 14:27:53 +0200 Subject: [PATCH 8/8] remove: function to remove voron brandings from mainsail, mainsail has its own logo now (thx @lixxbox). function therefore obsolete --- scripts/functions.sh | 66 ++++++++++++++++++------------------- scripts/ui/advanced_menu.sh | 20 +++++------ 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/scripts/functions.sh b/scripts/functions.sh index 05735b0..264ede2 100755 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -189,39 +189,39 @@ print_error(){ fi } -remove_branding(){ - echo - top_border - echo -e "| This action will remove the Voron brandings from |" - echo -e "| your Mainsail installation. You have to perform |" - echo -e "| this action again, everytime you updated Mainsail. |" - bottom_border - while true; do - read -p "${cyan}###### Do you want to continue? (Y/n):${default} " yn - case "$yn" in - Y|y|Yes|yes|"") - cd $MAINSAIL_DIR/css - FILE=$(find -name "app.*.css" | cut -d"/" -f2) - status_msg "Patching file '$FILE' ..." - cp -n $KLIPPER_DIR/docs/img/klipper-logo-small.png $MAINSAIL_DIR/img/ - #write extra lines to app.css - echo >> "$FILE" - cat < ${HOME}/kiauh/resources/app.css >> "$FILE" - ok_msg "File '$FILE' patched!" - status_msg "Setting new Favicon ..." - #backup old favicon - cp -n $MAINSAIL_DIR/favicon.ico $MAINSAIL_DIR/voron_favicon.ico - cp ${HOME}/kiauh/resources/favicon.ico $MAINSAIL_DIR/favicon.ico - ok_msg "Icon set!" - echo - ok_msg "Brandings removed!" - ok_msg "Clear browser cache and reload Mainsail (F5)!" - echo - break;; - N|n|No|no) break;; - esac - done -} +#remove_branding(){ +# echo +# top_border +# echo -e "| This action will remove the Voron brandings from |" +# echo -e "| your Mainsail installation. You have to perform |" +# echo -e "| this action again, everytime you updated Mainsail. |" +# bottom_border +# while true; do +# read -p "${cyan}###### Do you want to continue? (Y/n):${default} " yn +# case "$yn" in +# Y|y|Yes|yes|"") +# cd $MAINSAIL_DIR/css +# FILE=$(find -name "app.*.css" | cut -d"/" -f2) +# status_msg "Patching file '$FILE' ..." +# cp -n $KLIPPER_DIR/docs/img/klipper-logo-small.png $MAINSAIL_DIR/img/ +# #write extra lines to app.css +# echo >> "$FILE" +# cat < ${HOME}/kiauh/resources/app.css >> "$FILE" +# ok_msg "File '$FILE' patched!" +# status_msg "Setting new Favicon ..." +# #backup old favicon +# cp -n $MAINSAIL_DIR/favicon.ico $MAINSAIL_DIR/voron_favicon.ico +# cp ${HOME}/kiauh/resources/favicon.ico $MAINSAIL_DIR/favicon.ico +# ok_msg "Icon set!" +# echo +# ok_msg "Brandings removed!" +# ok_msg "Clear browser cache and reload Mainsail (F5)!" +# echo +# break;; +# N|n|No|no) break;; +# esac +# done +#} install_extension_shell_command(){ echo diff --git a/scripts/ui/advanced_menu.sh b/scripts/ui/advanced_menu.sh index 2e92b71..87d3967 100755 --- a/scripts/ui/advanced_menu.sh +++ b/scripts/ui/advanced_menu.sh @@ -8,11 +8,11 @@ advanced_ui(){ echo -e "| Klipper: | System: | " echo -e "| 1) [Switch Version] | 6) [Change hostname] | " echo -e "| 2) [Rollback] | | " - echo -e "| | Mainsail: | " - echo -e "| Firmware: | 7) [Remove branding] | " + echo -e "| | Extensions: | " + echo -e "| Firmware: | 7) [Shell Command] | " echo -e "| 3) [Build only] | | " - echo -e "| 4) [Build + Flash MCU] | Extensions: | " - echo -e "| 5) [Get Printer-USB] | 8) [Shell Command] | " + echo -e "| 4) [Build + Flash MCU] | | " + echo -e "| 5) [Get Printer-USB] | | " echo -e "| | | " quit_footer } @@ -76,13 +76,13 @@ advanced_menu(){ create_custom_hostname print_msg && clear_msg advanced_ui;; + #7) + # clear + # print_header + # remove_branding + # print_msg && clear_msg + # advanced_ui;; 7) - clear - print_header - remove_branding - print_msg && clear_msg - advanced_ui;; - 8) clear print_header install_extension_shell_command