Skip to content

Commit 0ccd712

Browse files
authored
Merge pull request #22 from TypQxQ/dev
Installation updates and renaming of macros folder
2 parents b164e77 + 0255d47 commit 0ccd712

File tree

9 files changed

+36
-24
lines changed

9 files changed

+36
-24
lines changed

README.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,14 @@ Thank you!
7676
### 1\. Automatic install with Moonraker Autoupdate Support
7777
This plugin assumes that you installed Klipper into your home directory (usually `/home/pi`).
7878

79-
1) Clone this repo into your home directory where Klipper is installed:
79+
Connect to your klipper machine using SSH and run these command:
8080
```
81-
cd ~
82-
git clone https://github.com/TypQxQ/KTC.git
81+
cd ~/ && git clone https://github.com/TypQxQ/KTC.git && bash ~/KTC/install.sh
8382
```
8483

85-
2) Run the `install.sh` script
86-
```
87-
~/KTC/install.sh
88-
```
84+
This will install and configure everything.
8985

90-
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.
86+
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.
9187

9288
### 2\. Manual Install
9389
Copy or link the python (`*.py`) files into the `\klipper\klippy\extras` directory. Assuming Then restart Klipper to pick up the extensions.

install.sh

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ verify_ready()
132132
function nextfilename {
133133
local name="$1"
134134
if [ -d "${name}" ]; then
135-
printf "%s-%s ${name%%.*} $(date +%Y%m%d_%H%M%S)"
135+
printf "%s-%s" ${name%%.*} $(date '+%Y%m%d_%H%M%S')
136136
else
137-
printf "%s-%s.%s-old ${name%%.*} $(date +%Y%m%d_%H%M%S) ${name#*.}"
137+
printf "%s-%s.%s-old" ${name%%.*} $(date '+%Y%m%d_%H%M%S') ${name#*.}
138138
fi
139139
}
140140

@@ -163,14 +163,14 @@ install_update_manager() {
163163
already_included=$(grep -c "\[update_manager KTC\]" ${dest} || true)
164164
if [ "${already_included}" -eq 0 ]; then
165165
# Backup the original moonraker.conf file
166-
next_dest="$(nextfilename "$dest")"
166+
next_dest="$(nextfilename $dest)"
167167
log_info "Copying original moonraker.conf file to ${next_dest}"
168-
cp "${dest} ${next_dest}"
168+
cp ${dest} ${next_dest}
169169

170170
# Add the configuration to moonraker.conf
171171
echo "" >> "${dest}" # Add a blank line
172172
echo "" >> "${dest}" # Add a blank line
173-
echo -e "[update_manager KTC\]" >> "${dest}" # Add the section header
173+
echo -e "[update_manager KTC]" >> "${dest}" # Add the section header
174174
echo -e "type: git_repo" >> "${dest}"
175175
echo -e "path: ${REPO_DIR}" >> "${dest}"
176176
echo -e "origin: https://github.com/TypQxQ/KTC.git" >> "${dest}"
@@ -203,6 +203,7 @@ install_klipper_config() {
203203

204204
# Add the configuration to printer.cfg
205205
# This example assumes that that both the server and the webcam stream are running on the same machine as Klipper
206+
# The ktc section is not needed if a tool is configured but loaded here for the macros to work if no tool is configured
206207
already_included=$(grep -c "\[ktc\]" ${dest} || true)
207208
if [ "${already_included}" -eq 0 ]; then
208209
echo "" >> "${dest}" # Add a blank line
@@ -214,24 +215,39 @@ install_klipper_config() {
214215
else
215216
log_error "[ktc] already exists in printer.cfg - skipping adding it there"
216217
fi
218+
219+
# Add the inclusion of macros to printer.cfg if it doesn't exist
220+
already_included=$(grep -c "\[include ktc/base/*.cfg\]" ${dest} || true)
221+
if [ "${already_included}" -eq 0 ]; then
222+
echo "" >> "${dest}" # Add a blank line
223+
echo -e "[include ktc/base/*.cfg]" >> "${dest}" # Add the section header
224+
echo -e "[include ktc/optional_rrf_compability/*.cfg]" >> "${dest}" # Add the section header
225+
else
226+
log_error "[include ktc/base/*.cfg] already exists in printer.cfg - skipping adding it and the optional macros there"
227+
fi
217228
else
218229
log_error "File printer.cfg file not found! Cannot add KTC configuration. Do it manually."
219230
fi
220231

221-
# Add the inclusion of macros.cfg to printer.cfg if it doesn't exist
222-
already_included=$(grep -c "\[include ktc_macros.cfg\]" ${dest} || true)
223-
if [ "${already_included}" -eq 0 ]; then
224-
echo "" >> "${dest}" # Add a blank line
225-
echo -e "[include ktc-macros.cfg]" >> "${dest}" # Add the section header
232+
if [ ! -d "${KLIPPER_CONFIG_HOME}/ktc" ]; then
233+
log_info "Creating the ${KLIPPER_CONFIG_HOME}/ktc directory"
234+
mkdir ${KLIPPER_CONFIG_HOME}/ktc
226235
else
227-
log_error "[include ktc-macros.cfg] already exists in printer.cfg - skipping adding it there"
236+
log_error "ktc directory already exists in ${KLIPPER_CONFIG_HOME} - skipping creating it"
228237
fi
229-
230-
if [ ! -f "${KLIPPER_CONFIG_HOME}/ktc-macros.cfg" ]; then
231-
log_info "Copying ktc-macros.cfg to ${KLIPPER_CONFIG_HOME}"
232-
cp "${REPO_DIR}/ktc-macros.cfg ${KLIPPER_CONFIG_HOME}"
238+
239+
if [ ! -d "${KLIPPER_CONFIG_HOME}/ktc/base" ]; then
240+
log_info "Copying base macros to ${KLIPPER_CONFIG_HOME}/ktc"
241+
cp -r ${REPO_DIR}/macros/base ${KLIPPER_CONFIG_HOME}/ktc
242+
else
243+
log_error "Base macros already exists in ${KLIPPER_CONFIG_HOME}/ktc/base - skipping copying it there"
244+
fi
245+
246+
if [ ! -d "${KLIPPER_CONFIG_HOME}/ktc/optional_rrf_compability" ]; then
247+
log_info "Copying optional_rrf_compability macros to ${KLIPPER_CONFIG_HOME}/ktc"
248+
cp -r ${REPO_DIR}/macros/optional_rrf_compability ${KLIPPER_CONFIG_HOME}/ktc
233249
else
234-
log_error "[include ktc-macros.cfg] already exists in printer.cfg - skipping adding it there"
250+
log_error "Optional RRF compability macros already exists in ${KLIPPER_CONFIG_HOME}/ktc/optional_rrf_compability - skipping copying it there"
235251
fi
236252
# Restart Klipper
237253
restart_klipper

0 commit comments

Comments
 (0)