From a0920a6f879a3d936fab8dd06af919620be8ecfc Mon Sep 17 00:00:00 2001 From: Carl Kittelberger Date: Thu, 22 May 2025 15:19:30 +0200 Subject: [PATCH] Only attempt to disable service if still installed. --- install.sh | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index 694946d..ba4c901 100755 --- a/install.sh +++ b/install.sh @@ -54,14 +54,21 @@ install_files() { } remove_file() { + local path="$1" sha256hash="${2:-}" + if [ -n "${sha256hash}" ]; then + if ! check_file "${path}" "${sha256hash}"; then + return + fi + fi + rm -v "$path" +} + +check_file() { local path="$1" sha256hash="${2:-}" if [ ! -f "$path" ]; then return fi - if [ -n "${sha256hash}" ] && ! sha256sum -c - <<< "${sha256hash} ${path}" >/dev/null 2>/dev/null; then - return - fi - rm -v "$path" + sha256sum -c - <<< "${sha256hash} ${path}" >/dev/null 2>/dev/null } ### @@ -74,8 +81,10 @@ if command -v fc-cache >/dev/null 2>&1; then fi if command -v systemctl >/dev/null 2>&1; then - systemctl --user disable tweak-cpu-usage - remove_file "${HOME}/.config/systemd/user/tweak-cpu-usage.service" 6abf4488aa268b0171cb400270e2531c8fb067ebe8216c72d337f8c056952f9e + if check_file "${HOME}/.config/systemd/user/tweak-cpu-usage.service" 6abf4488aa268b0171cb400270e2531c8fb067ebe8216c72d337f8c056952f9e; then + systemctl --user disable tweak-cpu-usage || true + remove_file "${HOME}/.config/systemd/user/tweak-cpu-usage.service" + fi remove_file "${HOME}/.local/bin/tweak-cpu-usage" 7da1938cdf78e583140638848f8bf8a268c2710e4fa3462bca8373e438d67491 fi