From f3536e4de3069cd37d0c78c94ee2abf58a5e9801 Mon Sep 17 00:00:00 2001 From: Andrei Ignat Date: Fri, 29 Mar 2024 21:54:17 +0100 Subject: [PATCH 1/7] Update README.md Update automatic installation --- README.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 290f8c7..87d3d18 100644 --- a/README.md +++ b/README.md @@ -76,18 +76,14 @@ Thank you! ### 1\. Automatic install with Moonraker Autoupdate Support This plugin assumes that you installed Klipper into your home directory (usually `/home/pi`). -1) Clone this repo into your home directory where Klipper is installed: +Connect to your klipper machine using SSH and run these command: ``` -cd ~ -git clone https://github.com/TypQxQ/KTC.git +cd ~/ && git clone https://github.com/TypQxQ/KTC.git && bash ~/KTC/install.sh ``` -2) Run the `install.sh` script -``` -~/KTC/install.sh -``` +This will install and configure everything. -If you encouter errors after an automatic Klipper update you can safetly run the `install.sh` scipt again to repair the links to the extension. +If you encouter errors after an automatic Klipper update you can safetly run the `install.sh` scipt inside the KTC directory again to repair the links to the extension. ### 2\. Manual Install Copy or link the python (`*.py`) files into the `\klipper\klippy\extras` directory. Assuming Then restart Klipper to pick up the extensions. From 1ee66b5e4495e9a025813c98721d16cf5c3df58e Mon Sep 17 00:00:00 2001 From: Andrei Ignat Date: Fri, 29 Mar 2024 22:20:44 +0100 Subject: [PATCH 2/7] Update install.sh --- install.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index 31928b0..a6463ca 100644 --- a/install.sh +++ b/install.sh @@ -132,9 +132,9 @@ verify_ready() function nextfilename { local name="$1" if [ -d "${name}" ]; then - printf "%s-%s ${name%%.*} $(date +%Y%m%d_%H%M%S)" + printf "%s-%s" ${name%%.*} $(date '+%Y%m%d_%H%M%S') else - printf "%s-%s.%s-old ${name%%.*} $(date +%Y%m%d_%H%M%S) ${name#*.}" + printf "%s-%s.%s-old" ${name%%.*} $(date '+%Y%m%d_%H%M%S') ${name#*.} fi } @@ -163,9 +163,9 @@ install_update_manager() { already_included=$(grep -c "\[update_manager KTC\]" ${dest} || true) if [ "${already_included}" -eq 0 ]; then # Backup the original moonraker.conf file - next_dest="$(nextfilename "$dest")" + next_dest="$(nextfilename $dest)" log_info "Copying original moonraker.conf file to ${next_dest}" - cp "${dest} ${next_dest}" + cp ${dest} ${next_dest} # Add the configuration to moonraker.conf echo "" >> "${dest}" # Add a blank line @@ -218,7 +218,7 @@ install_klipper_config() { log_error "File printer.cfg file not found! Cannot add KTC configuration. Do it manually." fi - # Add the inclusion of macros.cfg to printer.cfg if it doesn't exist + # Add the inclusion of macros to printer.cfg if it doesn't exist already_included=$(grep -c "\[include ktc_macros.cfg\]" ${dest} || true) if [ "${already_included}" -eq 0 ]; then echo "" >> "${dest}" # Add a blank line @@ -229,7 +229,7 @@ install_klipper_config() { if [ ! -f "${KLIPPER_CONFIG_HOME}/ktc-macros.cfg" ]; then log_info "Copying ktc-macros.cfg to ${KLIPPER_CONFIG_HOME}" - cp "${REPO_DIR}/ktc-macros.cfg ${KLIPPER_CONFIG_HOME}" + cp ${REPO_DIR}/ktc-macros.cfg ${KLIPPER_CONFIG_HOME} else log_error "[include ktc-macros.cfg] already exists in printer.cfg - skipping adding it there" fi From 529d98da947baf471245f908f58bf688275a91f8 Mon Sep 17 00:00:00 2001 From: TypQxQ Date: Fri, 29 Mar 2024 22:29:35 +0100 Subject: [PATCH 3/7] Rename macros directory --- macros/{overrides => base}/M104.cfg | 0 macros/{overrides => base}/M106.cfg | 0 macros/{overrides => base}/M107.cfg | 0 macros/{overrides => base}/M109.cfg | 0 macros/{rrf_compability => optional_rrf_compability}/G10.cfg | 0 macros/{rrf_compability => optional_rrf_compability}/M116.cfg | 0 macros/{rrf_compability => optional_rrf_compability}/M568.cfg | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename macros/{overrides => base}/M104.cfg (100%) rename macros/{overrides => base}/M106.cfg (100%) rename macros/{overrides => base}/M107.cfg (100%) rename macros/{overrides => base}/M109.cfg (100%) rename macros/{rrf_compability => optional_rrf_compability}/G10.cfg (100%) rename macros/{rrf_compability => optional_rrf_compability}/M116.cfg (100%) rename macros/{rrf_compability => optional_rrf_compability}/M568.cfg (100%) diff --git a/macros/overrides/M104.cfg b/macros/base/M104.cfg similarity index 100% rename from macros/overrides/M104.cfg rename to macros/base/M104.cfg diff --git a/macros/overrides/M106.cfg b/macros/base/M106.cfg similarity index 100% rename from macros/overrides/M106.cfg rename to macros/base/M106.cfg diff --git a/macros/overrides/M107.cfg b/macros/base/M107.cfg similarity index 100% rename from macros/overrides/M107.cfg rename to macros/base/M107.cfg diff --git a/macros/overrides/M109.cfg b/macros/base/M109.cfg similarity index 100% rename from macros/overrides/M109.cfg rename to macros/base/M109.cfg diff --git a/macros/rrf_compability/G10.cfg b/macros/optional_rrf_compability/G10.cfg similarity index 100% rename from macros/rrf_compability/G10.cfg rename to macros/optional_rrf_compability/G10.cfg diff --git a/macros/rrf_compability/M116.cfg b/macros/optional_rrf_compability/M116.cfg similarity index 100% rename from macros/rrf_compability/M116.cfg rename to macros/optional_rrf_compability/M116.cfg diff --git a/macros/rrf_compability/M568.cfg b/macros/optional_rrf_compability/M568.cfg similarity index 100% rename from macros/rrf_compability/M568.cfg rename to macros/optional_rrf_compability/M568.cfg From c793a9df941f02891b59300503a6134016cf1e1a Mon Sep 17 00:00:00 2001 From: TypQxQ Date: Fri, 29 Mar 2024 22:54:31 +0100 Subject: [PATCH 4/7] Rewrite install.sh for macros. --- install.sh | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/install.sh b/install.sh index a6463ca..74868c1 100644 --- a/install.sh +++ b/install.sh @@ -203,6 +203,7 @@ install_klipper_config() { # Add the configuration to printer.cfg # This example assumes that that both the server and the webcam stream are running on the same machine as Klipper + # The ktc section is not needed if a tool is configured but loaded here for the macros to work if no tool is configured already_included=$(grep -c "\[ktc\]" ${dest} || true) if [ "${already_included}" -eq 0 ]; then echo "" >> "${dest}" # Add a blank line @@ -214,24 +215,42 @@ install_klipper_config() { else log_error "[ktc] already exists in printer.cfg - skipping adding it there" fi + + # Add the inclusion of macros to printer.cfg if it doesn't exist + already_included=$(grep -c "[include ktc/base/*.cfg]" ${dest} || true) + if [ "${already_included}" -eq 0 ]; then + echo "" >> "${dest}" # Add a blank line + echo -e "[include ktc/base/*.cfg]" >> "${dest}" # Add the section header + echo -e "[include ktc/optional_rrf_compability/*.cfg]" >> "${dest}" # Add the section header + log_imprtant "Added KTC macros to printer.cfg" + else + log_error "[include ktc/base/*.cfg] already exists in printer.cfg - skipping adding it and the optional macros there" + fi else log_error "File printer.cfg file not found! Cannot add KTC configuration. Do it manually." fi - # Add the inclusion of macros to printer.cfg if it doesn't exist - already_included=$(grep -c "\[include ktc_macros.cfg\]" ${dest} || true) - if [ "${already_included}" -eq 0 ]; then - echo "" >> "${dest}" # Add a blank line - echo -e "[include ktc-macros.cfg]" >> "${dest}" # Add the section header + if [ ! -d "${KLIPPER_CONFIG_HOME}/ktc" ]; then + log_info "Creating the ${KLIPPER_CONFIG_HOME}/ktc directory" + mkdir ${KLIPPER_CONFIG_HOME}/ktc else - log_error "[include ktc-macros.cfg] already exists in printer.cfg - skipping adding it there" + log_error "ktc directory already exists in ${KLIPPER_CONFIG_HOME} - skipping creating it" fi - - if [ ! -f "${KLIPPER_CONFIG_HOME}/ktc-macros.cfg" ]; then - log_info "Copying ktc-macros.cfg to ${KLIPPER_CONFIG_HOME}" - cp ${REPO_DIR}/ktc-macros.cfg ${KLIPPER_CONFIG_HOME} + + if [ ! -d "${KLIPPER_CONFIG_HOME}/ktc/base" ]; then + log_info "Copying base macros to ${KLIPPER_CONFIG_HOME}/ktc" + cp -r ${REPO_DIR}/macros/base ${KLIPPER_CONFIG_HOME}/ktc + # cp ${REPO_DIR}/macros/base/*.cfg ${KLIPPER_CONFIG_HOME}/ktc/base + else + log_error "Base macros already exists in ${KLIPPER_CONFIG_HOME}/ktc/base - skipping copying it there" + fi + + if [ ! -d "${KLIPPER_CONFIG_HOME}/ktc/optional_rrf_compability" ]; then + log_info "Copying optional_rrf_compability macros to ${KLIPPER_CONFIG_HOME}/ktc" + cp -r ${REPO_DIR}/macros/optional_rrf_compability ${KLIPPER_CONFIG_HOME}/ktc + # cp ${REPO_DIR}/macros/optional_rrf_compability/*.cfg ${KLIPPER_CONFIG_HOME}/ktc/optional_rrf_compability else - log_error "[include ktc-macros.cfg] already exists in printer.cfg - skipping adding it there" + log_error "Optional RRF compability macros already exists in ${KLIPPER_CONFIG_HOME}/ktc/optional_rrf_compability - skipping copying it there" fi # Restart Klipper restart_klipper From f60dbcb9871c8947a302a7899992565e49f50c28 Mon Sep 17 00:00:00 2001 From: Andrei Ignat Date: Fri, 29 Mar 2024 22:55:46 +0100 Subject: [PATCH 5/7] Update install.sh --- install.sh | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/install.sh b/install.sh index a6463ca..74868c1 100644 --- a/install.sh +++ b/install.sh @@ -203,6 +203,7 @@ install_klipper_config() { # Add the configuration to printer.cfg # This example assumes that that both the server and the webcam stream are running on the same machine as Klipper + # The ktc section is not needed if a tool is configured but loaded here for the macros to work if no tool is configured already_included=$(grep -c "\[ktc\]" ${dest} || true) if [ "${already_included}" -eq 0 ]; then echo "" >> "${dest}" # Add a blank line @@ -214,24 +215,42 @@ install_klipper_config() { else log_error "[ktc] already exists in printer.cfg - skipping adding it there" fi + + # Add the inclusion of macros to printer.cfg if it doesn't exist + already_included=$(grep -c "[include ktc/base/*.cfg]" ${dest} || true) + if [ "${already_included}" -eq 0 ]; then + echo "" >> "${dest}" # Add a blank line + echo -e "[include ktc/base/*.cfg]" >> "${dest}" # Add the section header + echo -e "[include ktc/optional_rrf_compability/*.cfg]" >> "${dest}" # Add the section header + log_imprtant "Added KTC macros to printer.cfg" + else + log_error "[include ktc/base/*.cfg] already exists in printer.cfg - skipping adding it and the optional macros there" + fi else log_error "File printer.cfg file not found! Cannot add KTC configuration. Do it manually." fi - # Add the inclusion of macros to printer.cfg if it doesn't exist - already_included=$(grep -c "\[include ktc_macros.cfg\]" ${dest} || true) - if [ "${already_included}" -eq 0 ]; then - echo "" >> "${dest}" # Add a blank line - echo -e "[include ktc-macros.cfg]" >> "${dest}" # Add the section header + if [ ! -d "${KLIPPER_CONFIG_HOME}/ktc" ]; then + log_info "Creating the ${KLIPPER_CONFIG_HOME}/ktc directory" + mkdir ${KLIPPER_CONFIG_HOME}/ktc else - log_error "[include ktc-macros.cfg] already exists in printer.cfg - skipping adding it there" + log_error "ktc directory already exists in ${KLIPPER_CONFIG_HOME} - skipping creating it" fi - - if [ ! -f "${KLIPPER_CONFIG_HOME}/ktc-macros.cfg" ]; then - log_info "Copying ktc-macros.cfg to ${KLIPPER_CONFIG_HOME}" - cp ${REPO_DIR}/ktc-macros.cfg ${KLIPPER_CONFIG_HOME} + + if [ ! -d "${KLIPPER_CONFIG_HOME}/ktc/base" ]; then + log_info "Copying base macros to ${KLIPPER_CONFIG_HOME}/ktc" + cp -r ${REPO_DIR}/macros/base ${KLIPPER_CONFIG_HOME}/ktc + # cp ${REPO_DIR}/macros/base/*.cfg ${KLIPPER_CONFIG_HOME}/ktc/base + else + log_error "Base macros already exists in ${KLIPPER_CONFIG_HOME}/ktc/base - skipping copying it there" + fi + + if [ ! -d "${KLIPPER_CONFIG_HOME}/ktc/optional_rrf_compability" ]; then + log_info "Copying optional_rrf_compability macros to ${KLIPPER_CONFIG_HOME}/ktc" + cp -r ${REPO_DIR}/macros/optional_rrf_compability ${KLIPPER_CONFIG_HOME}/ktc + # cp ${REPO_DIR}/macros/optional_rrf_compability/*.cfg ${KLIPPER_CONFIG_HOME}/ktc/optional_rrf_compability else - log_error "[include ktc-macros.cfg] already exists in printer.cfg - skipping adding it there" + log_error "Optional RRF compability macros already exists in ${KLIPPER_CONFIG_HOME}/ktc/optional_rrf_compability - skipping copying it there" fi # Restart Klipper restart_klipper From 2dcb3156df9094cb11d22e4086344c6e23064de6 Mon Sep 17 00:00:00 2001 From: Andrei Ignat Date: Fri, 29 Mar 2024 22:58:33 +0100 Subject: [PATCH 6/7] Update install.sh Delete some debug data --- install.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/install.sh b/install.sh index 74868c1..b1aefed 100644 --- a/install.sh +++ b/install.sh @@ -222,7 +222,6 @@ install_klipper_config() { echo "" >> "${dest}" # Add a blank line echo -e "[include ktc/base/*.cfg]" >> "${dest}" # Add the section header echo -e "[include ktc/optional_rrf_compability/*.cfg]" >> "${dest}" # Add the section header - log_imprtant "Added KTC macros to printer.cfg" else log_error "[include ktc/base/*.cfg] already exists in printer.cfg - skipping adding it and the optional macros there" fi @@ -240,7 +239,6 @@ install_klipper_config() { if [ ! -d "${KLIPPER_CONFIG_HOME}/ktc/base" ]; then log_info "Copying base macros to ${KLIPPER_CONFIG_HOME}/ktc" cp -r ${REPO_DIR}/macros/base ${KLIPPER_CONFIG_HOME}/ktc - # cp ${REPO_DIR}/macros/base/*.cfg ${KLIPPER_CONFIG_HOME}/ktc/base else log_error "Base macros already exists in ${KLIPPER_CONFIG_HOME}/ktc/base - skipping copying it there" fi @@ -248,7 +246,6 @@ install_klipper_config() { if [ ! -d "${KLIPPER_CONFIG_HOME}/ktc/optional_rrf_compability" ]; then log_info "Copying optional_rrf_compability macros to ${KLIPPER_CONFIG_HOME}/ktc" cp -r ${REPO_DIR}/macros/optional_rrf_compability ${KLIPPER_CONFIG_HOME}/ktc - # cp ${REPO_DIR}/macros/optional_rrf_compability/*.cfg ${KLIPPER_CONFIG_HOME}/ktc/optional_rrf_compability else log_error "Optional RRF compability macros already exists in ${KLIPPER_CONFIG_HOME}/ktc/optional_rrf_compability - skipping copying it there" fi From 0255d478cdc568463687148ef864bde080b2d2f5 Mon Sep 17 00:00:00 2001 From: Andrei Ignat Date: Fri, 29 Mar 2024 23:16:47 +0100 Subject: [PATCH 7/7] Update install.sh --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index b1aefed..a2e9518 100644 --- a/install.sh +++ b/install.sh @@ -170,7 +170,7 @@ install_update_manager() { # Add the configuration to moonraker.conf echo "" >> "${dest}" # Add a blank line echo "" >> "${dest}" # Add a blank line - echo -e "[update_manager KTC\]" >> "${dest}" # Add the section header + echo -e "[update_manager KTC]" >> "${dest}" # Add the section header echo -e "type: git_repo" >> "${dest}" echo -e "path: ${REPO_DIR}" >> "${dest}" echo -e "origin: https://github.com/TypQxQ/KTC.git" >> "${dest}" @@ -217,7 +217,7 @@ install_klipper_config() { fi # Add the inclusion of macros to printer.cfg if it doesn't exist - already_included=$(grep -c "[include ktc/base/*.cfg]" ${dest} || true) + already_included=$(grep -c "\[include ktc/base/*.cfg\]" ${dest} || true) if [ "${already_included}" -eq 0 ]; then echo "" >> "${dest}" # Add a blank line echo -e "[include ktc/base/*.cfg]" >> "${dest}" # Add the section header