From a0b9a78b19bdaf4d241ed3e515229842740820b3 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 13 Jun 2023 07:04:24 -0400 Subject: [PATCH] add some verification checks --- scripts/remove_printcfg.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/scripts/remove_printcfg.sh b/scripts/remove_printcfg.sh index de1cc27..7093584 100644 --- a/scripts/remove_printcfg.sh +++ b/scripts/remove_printcfg.sh @@ -48,7 +48,12 @@ fi systemctl stop $repo.service || { echo -e "\e[31mFailed to stop $repo service.\e[0m"; exit 1; } # Remove the printcfg service -sudo rm /etc/systemd/system/$repo.service +service_file="/etc/systemd/system/$repo.service" +if [ -f "$service_file" ]; then + sudo rm "$service_file" || { echo -e "\e[31mFailed to remove $service_file.\e[0m"; exit 1; } +else + echo -e "\e[31m$service_file does not exist.\e[0m" +fi # Verify that the printcfg service was removed if [ -f /etc/systemd/system/$repo.service ]; then @@ -75,8 +80,13 @@ if [ -d "$home"/$repo ]; then exit 1 fi -# Remove the printcfg symlink from the klipper config directory -sudo rm "$config"/$repo +# Remove the printcfg directory +sudo rm -rf "$home/$repo" +# Verify that the printcfg directory was removed +if [ -d "$home/$repo" ]; then + echo -e "\e[31mFailed to remove $home/$repo.\e[0m" + exit 1 +fi # Verify that the printcfg symlink was removed if [ -L "$config"/$repo ]; then