Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change installer to handle k1 creality os #200

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
KLIPPER_PATH="${HOME}/klipper"
AUTOTUNETMC_PATH="${HOME}/klipper_tmc_autotune"

IS_K1_OS=0
if grep -Fqs "ID=buildroot" /etc/os-release; then
KLIPPER_PATH="/usr/share/klipper"
AUTOTUNETMC_PATH="/usr/data/klipper_tmc_autotune"
IS_K1_OS=1
fi

set -eu
export LC_ALL=C

Expand All @@ -27,8 +34,9 @@ function check_download {
autotunebasename="$(basename ${AUTOTUNETMC_PATH})"

if [ ! -d "${AUTOTUNETMC_PATH}" ]; then

echo "[DOWNLOAD] Downloading Autotune TMC repository..."
if git -C $autotunedirname clone https://github.com/andrewmcgr/klipper_tmc_autotune.git $autotunebasename; then
if git -C $autotunedirname clone https://github.com/andrewmcgr/klipper_tmc_autotune.git ${AUTOTUNETMC_PATH}; then
chmod +x ${AUTOTUNETMC_PATH}/install.sh
printf "[DOWNLOAD] Download complete!\n\n"
else
Expand All @@ -42,14 +50,22 @@ function check_download {

function link_extension {
echo "[INSTALL] Linking extension to Klipper..."
ln -srfn "${AUTOTUNETMC_PATH}/autotune_tmc.py" "${KLIPPER_PATH}/klippy/extras/autotune_tmc.py"
ln -srfn "${AUTOTUNETMC_PATH}/motor_constants.py" "${KLIPPER_PATH}/klippy/extras/motor_constants.py"
ln -srfn "${AUTOTUNETMC_PATH}/motor_database.cfg" "${KLIPPER_PATH}/klippy/extras/motor_database.cfg"
LN_ARGS="-srfn"
if [[ $IS_K1_OS -eq 1 ]]; then
LN_ARGS="-sfn"
fi
ln $LN_ARGS "${AUTOTUNETMC_PATH}/autotune_tmc.py" "${KLIPPER_PATH}/klippy/extras/autotune_tmc.py"
ln $LN_ARGS "${AUTOTUNETMC_PATH}/motor_constants.py" "${KLIPPER_PATH}/klippy/extras/motor_constants.py"
ln $LN_ARGS "${AUTOTUNETMC_PATH}/motor_database.cfg" "${KLIPPER_PATH}/klippy/extras/motor_database.cfg"
}

function restart_klipper {
echo "[POST-INSTALL] Restarting Klipper..."
sudo systemctl restart klipper
if [[ $IS_K1_OS -eq 1 ]]; then
/etc/init.d/S55klipper_service restart
else
sudo systemctl restart klipper
fi
}


Expand All @@ -59,7 +75,9 @@ printf "======================================\n\n"


# Run steps
preflight_checks
if [[ $IS_K1_OS -ne 1 ]]; then
preflight_checks
fi
check_download
link_extension
restart_klipper