fix: prevent kill apt process by accident

This commit is contained in:
Gadfly 2025-03-04 18:00:15 +08:00
parent e28f8611ef
commit 3e2c589c8b
No known key found for this signature in database
2 changed files with 8 additions and 9 deletions

View file

@ -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
;;

View file

@ -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
;;