install script

This commit is contained in:
Félix Boisselier
2023-10-16 22:47:18 +02:00
parent 92b4e2a932
commit fe490855c3
2 changed files with 98 additions and 15 deletions

View File

@@ -9,13 +9,9 @@ It operates in two steps:
1. Utilizing specially tailored Klipper macros, it initiates tests on either the belts or the printer X/Y axis to measure the machine axes behavior. This is basically an automated call to the Klipper `TEST_RESONANCES` macro with custom parameters. 1. Utilizing specially tailored Klipper macros, it initiates tests on either the belts or the printer X/Y axis to measure the machine axes behavior. This is basically an automated call to the Klipper `TEST_RESONANCES` macro with custom parameters.
2. Then a custom Python script is called to: 2. Then a custom Python script is called to:
a. Generate insightful and improved graphs, aiding in parameter tuning for the Klipper `[input_shaper]` system (including best shaper choice, resonant frequency and damping ratio) or diagnosing and rectifying mechanical issues (like belt tension, defective bearings, etc..) 1. Generate insightful and improved graphs, aiding in parameter tuning for the Klipper `[input_shaper]` system (including best shaper choice, resonant frequency and damping ratio) or diagnosing and rectifying mechanical issues (like belt tension, defective bearings, etc..)
b. Relocates the graphs and associated CSV files to your Klipper config folder for easy access via Mainsail/Fluidd to eliminate the need for SSH. 2. Relocates the graphs and associated CSV files to your Klipper config folder for easy access via Mainsail/Fluidd to eliminate the need for SSH.
c. Manages the folder by retaining only the most recent results (default setting of keeping the latest three sets). 3. Manages the folder by retaining only the most recent results (default setting of keeping the latest three sets).
> **Note**:
>
> This module is part of the [Klippain](https://github.com/Frix-x/klippain) ecosystem. If you already have a full Klippain installation on your machine, no additional installation is required for you!
If needed, refer to [my IS graphs documentation](./docs/input_shaper.md) for tips on interpreting the generated graphs. If needed, refer to [my IS graphs documentation](./docs/input_shaper.md) for tips on interpreting the generated graphs.
@@ -26,19 +22,25 @@ If needed, refer to [my IS graphs documentation](./docs/input_shaper.md) for tip
## Installation ## Installation
For those not using the full [Klippain](https://github.com/Frix-x/klippain), follow these steps to integrate this Shake&Tune module in your setup: For those not using the full [Klippain](https://github.com/Frix-x/klippain), follow these steps to integrate this Shake&Tune module in your setup:
1. Add the [K-ShakeTune folder](./K-ShakeTune/) and its contents to the root of your config directory (e.g., `~/printer_data/config/`). 1. Run the install script over SSH on your printer:
2. Ensure the `gcode_shell_command.py` Klipper extension is installed. Use the advanced section of [KIAUH](https://github.com/dw-0/kiauh) for a straightforward installation.
3. Make the scripts executable via SSH within the folder (`cd ~/printer_data/config/K-ShakeTune/scripts`):
```bash ```bash
chmod +x ./is_workflow.py wget -O - https://raw.githubusercontent.com/Frix-x/klippain-shaketune/main/install.sh | bash
chmod +x ./graph_belts.py
chmod +x ./graph_shaper.py
chmod +x ./graph_vibrations.py
``` ```
4. Append the following to your `printer.cfg` file: 2. Append the following to your `printer.cfg` file:
``` ```
[include K-ShakeTune/*.cfg] [include K-ShakeTune/*.cfg]
``` ```
3. If you want to get automatic updates, add the following to your `moonraker.cfg` file:
```
[update_manager Klippain-ShakeTune]
type: git_repo
path: ~/klippain_shaketune
channel: beta
origin: https://github.com/Frix-x/klippain-shaketune.git
primary_branch: main
managed_services: klipper
install_script: install.sh
```
## Usage ## Usage

81
install.sh Executable file
View File

@@ -0,0 +1,81 @@
#!/bin/bash
USER_CONFIG_PATH="${HOME}/printer_data/config"
KLIPPER_PATH="${HOME}/klipper"
K_SHAKETUNE_PATH="${HOME}/klippain_shaketune"
set -eu
export LC_ALL=C
function preflight_checks {
if [ "$EUID" -eq 0 ]; then
echo "[PRE-CHECK] This script must not be run as root!"
exit -1
fi
if [ "$(sudo systemctl list-units --full -all -t service --no-legend | grep -F 'klipper.service')" ]; then
printf "[PRE-CHECK] Klipper service found! Continuing...\n\n"
else
echo "[ERROR] Klipper service not found, please install Klipper first!"
exit -1
fi
if [ -d "${HOME}/klippain_config" ]; then
if [ -f "${USER_CONFIG_PATH}/.VERSION" ]; then
echo "[ERROR] Klippain full installation found! Nothing is needed in order to use the K-Shake&Tune module!"
exit -1
fi
fi
}
function check_download {
local shaketunedirname shaketunebasename
shaketunedirname="$(dirname ${K_SHAKETUNE_PATH})"
shaketunebasename="$(basename ${K_SHAKETUNE_PATH})"
if [ ! -d "${K_SHAKETUNE_PATH}" ]; then
echo "[DOWNLOAD] Downloading Klippain Shake&Tune module repository..."
if git -C $shaketunedirname clone https://github.com/Frix-x/klippain-shaketune.git $shaketunebasename; then
chmod +x ${K_SHAKETUNE_PATH}/install.sh
printf "[DOWNLOAD] Download complete!\n\n"
else
echo "[ERROR] Download of Klippain Shake&Tune module git repository failed!"
exit -1
fi
else
printf "[DOWNLOAD] Klippain Shake&Tune module repository already found locally. Continuing...\n\n"
fi
}
function link_extension {
echo "[INSTALL] Linking scripts to your config directory..."
ln -frsn ${K_SHAKETUNE_PATH}/K-ShakeTune ${USER_CONFIG_PATH}/K-ShakeTune
}
function link_gcodeshellcommandpy {
if [ ! -f "${KLIPPER_PATH}/klippy/extras/gcode_shell_command.py" ]; then
echo "[INSTALL] Downloading gcode_shell_command.py Klipper extension needed for this module"
wget -P ${KLIPPER_PATH}/klippy/extras https://raw.githubusercontent.com/Frix-x/klippain/main/scripts/gcode_shell_command.py
else
printf "[INSTALL] gcode_shell_command.py Klipper extension is already installed. Continuing...\n\n"
fi
}
function restart_klipper {
echo "[POST-INSTALL] Restarting Klipper..."
sudo systemctl restart klipper
}
printf "\n=============================================\n"
echo "- Klippain Shake&Tune module install script -"
printf "=============================================\n\n"
# Run steps
preflight_checks
check_download
link_extension
link_gcodeshellcommandpy
restart_klipper