From bad58762bbad846fd853e81283a6b29297f9d4f5 Mon Sep 17 00:00:00 2001 From: Magne Rasmussen Date: Fri, 19 Jan 2024 08:12:12 +0100 Subject: [PATCH 1/6] Make sure we clean up everything we install. --- uninstall.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/uninstall.sh b/uninstall.sh index 71d543575..925d8c743 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -76,6 +76,8 @@ function delete_current_klippain { else echo "[WARNING] Klippain path not found! Nothing to delete here. Continuing..." fi + + rm -f ${KLIPPER_PATH}/klippy/extras/gcode_shell_command.py } # Step 3: Find the latest backup without a .VERSION file and restore it if needed From 72cd9b1fc57d1f84a28966c80e49a0fd320468af Mon Sep 17 00:00:00 2001 From: Magne Rasmussen Date: Fri, 19 Jan 2024 08:13:30 +0100 Subject: [PATCH 2/6] Don't fail uninstall if the backup folder has been removed. --- uninstall.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/uninstall.sh b/uninstall.sh index 925d8c743..7ffa72411 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -84,6 +84,11 @@ function delete_current_klippain { function restore_latest_backup { local restore_backup latest_backup + if [[ ! -e "${BACKUP_PATH}" ]]; then + printf "[RESTORE] No backup folder found! Skipping...\n\n" + return + fi + read < /dev/tty -rp "[RESTORE] Would you like to restore your last config backup? This script will look for the last one before running Klippain (Y/n) " restore_backup if [[ -z "$restore_backup" ]]; then restore_backup="y" From 77cae4f8d9eb886a67f12e6b40a46a4749b79c3e Mon Sep 17 00:00:00 2001 From: Magne Rasmussen Date: Fri, 19 Jan 2024 08:19:33 +0100 Subject: [PATCH 3/6] Make uninstall work when backup has sub-directories. If the backup has sub-directories, one of the sub-directories are currently restored. This fix will make sure we only consider the top-level backup directories. --- uninstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uninstall.sh b/uninstall.sh index 7ffa72411..2a7252725 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -101,7 +101,7 @@ function restore_latest_backup { return fi - latest_backup=$(find ${BACKUP_PATH} -type d -not -path "${BACKUP_PATH}" -exec sh -c 'if [ ! -f "$1/.VERSION" ]; then echo "$1"; fi' sh {} \; | sort -r | head -n 1) + latest_backup=$(find ${BACKUP_PATH} -maxdepth 1 -type d -not -path "${BACKUP_PATH}" -exec sh -c 'if [ ! -f "$1/.VERSION" ]; then echo "$1"; fi' sh {} \; | sort -r | head -n 1) if [ -n "${latest_backup}" ]; then cp -fa ${latest_backup}/. ${USER_CONFIG_PATH} 2>/dev/null || : printf "[RESTORE] Latest backup restored from: ${latest_backup}\n\n" From 5e55523986c758d2bc9f100f62e31c114e6ce39d Mon Sep 17 00:00:00 2001 From: Magne Rasmussen Date: Fri, 19 Jan 2024 08:31:16 +0100 Subject: [PATCH 4/6] The install.sh file is made executable elsewhere. --- install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/install.sh b/install.sh index a551732ad..0e2c32524 100755 --- a/install.sh +++ b/install.sh @@ -80,7 +80,6 @@ function check_download { if [ ! -d "${FRIX_CONFIG_PATH}" ]; then echo "[DOWNLOAD] Downloading Klippain repository..." if git -C $frixtemppath clone -b $frixbranchname https://github.com/Frix-x/klippain.git $frixreponame; then - chmod +x ${FRIX_CONFIG_PATH}/install.sh printf "[DOWNLOAD] Download complete!\n\n" else echo "[ERROR] Download of Klippain git repository failed!" From de96457614ffafee855394b8a286ca0cc38292fc Mon Sep 17 00:00:00 2001 From: Magne Rasmussen Date: Fri, 19 Jan 2024 08:32:33 +0100 Subject: [PATCH 5/6] Make sure we don't fail making backup. If there is no user config directory, don't fail; we will recreate it. Also, make sure we don't fail if we need to remove the user config directory. --- install.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 0e2c32524..27b7d9f03 100755 --- a/install.sh +++ b/install.sh @@ -93,6 +93,11 @@ function check_download { # Step 3: Backup the old Klipper configuration function backup_config { + if [ ! -e "${USER_CONFIG_PATH}" ]; then + printf "[BACKUP] No previous config found, skipping backup...\n\n" + return 0 + fi + mkdir -p ${BACKUP_DIR} # Copy every files from the user config ("2>/dev/null || :" allow it to fail silentely in case the config dir doesn't exist) @@ -103,7 +108,7 @@ function backup_config { # If Klippain is not already installed (we check for .VERSION in the backup to detect it), # we need to remove, wipe and clean the current user config folder... if [ ! -f "${BACKUP_DIR}/.VERSION" ]; then - rm -R ${USER_CONFIG_PATH} + rm -fR ${USER_CONFIG_PATH} fi printf "[BACKUP] Backup of current user config files done in: ${BACKUP_DIR}\n\n" From d0a8e382c425737845f5aecea7dd93792953f43f Mon Sep 17 00:00:00 2001 From: Magne Rasmussen Date: Fri, 1 Mar 2024 08:58:12 +0100 Subject: [PATCH 6/6] Don't remove gcode_shell_command.py. It may not have been put there by klippain. --- uninstall.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/uninstall.sh b/uninstall.sh index 2a7252725..378e251ea 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -76,8 +76,6 @@ function delete_current_klippain { else echo "[WARNING] Klippain path not found! Nothing to delete here. Continuing..." fi - - rm -f ${KLIPPER_PATH}/klippy/extras/gcode_shell_command.py } # Step 3: Find the latest backup without a .VERSION file and restore it if needed