From 71d0b69eee5d48f0118d0c8bd8029a7bf73497bc Mon Sep 17 00:00:00 2001 From: GadflyFang Date: Tue, 4 Mar 2025 19:51:36 +0800 Subject: [PATCH] fix: prevent kill apt process by accident (#1054) --- build/resources/deb/DEBIAN/preinst | 8 ++++---- build/resources/deb/DEBIAN/prerm | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/build/resources/deb/DEBIAN/preinst b/build/resources/deb/DEBIAN/preinst index edcf9088..a93f8090 100755 --- a/build/resources/deb/DEBIAN/preinst +++ b/build/resources/deb/DEBIAN/preinst @@ -12,10 +12,10 @@ set -e case "$1" in install|upgrade) # Check if SourceGit is running and stop it - if pidof -q sourcegit || pgrep -f sourcegit > /dev/null; then - echo "SourceGit is running, stopping it..." - killall sourcegit 2>/dev/null || pkill -f sourcegit 2>/dev/null || true - # Wait for SourceGit to exit + if pgrep -f '/opt/sourcegit/sourcegit' > /dev/null; then + echo "Stopping running SourceGit instance..." + pkill -f '/opt/sourcegit/sourcegit' || true + # Give the process a moment to terminate sleep 1 fi ;; diff --git a/build/resources/deb/DEBIAN/prerm b/build/resources/deb/DEBIAN/prerm index 8ecd4b8d..c2c9e4f0 100755 --- a/build/resources/deb/DEBIAN/prerm +++ b/build/resources/deb/DEBIAN/prerm @@ -15,11 +15,10 @@ set -e case "$1" in remove|upgrade|deconfigure) - # Check if SourceGit is running and stop it - if pidof -q sourcegit || pgrep -f sourcegit > /dev/null; then - echo "SourceGit is running, stopping it before removal..." - killall sourcegit 2>/dev/null || pkill -f sourcegit 2>/dev/null || true - # Wait for SourceGit to exit + if pgrep -f '/opt/sourcegit/sourcegit' > /dev/null; then + echo "Stopping running SourceGit instance..." + pkill -f '/opt/sourcegit/sourcegit' || true + # Give the process a moment to terminate sleep 1 fi ;;