fix: 修复 apt 升级后服务需要手动重新启用的问题
All checks were successful
Build and Release Mond / build-and-test (arm64) (push) Successful in -17s
Build and Release Mond / build-and-test (amd64) (push) Successful in -19s
Build and Release Mond / release (push) Has been skipped

- 修改 prerm 脚本,升级时只停止服务不禁用
- 修改 postinst 脚本,升级后自动重启已启用的服务
- 首次安装仍保持手动启用服务的行为
This commit is contained in:
2026-01-21 12:40:29 +08:00
parent 2d47652a06
commit 1faa92266e
2 changed files with 43 additions and 16 deletions

43
debian/prerm vendored
View File

@@ -1,17 +1,36 @@
#!/bin/sh
set -e
# Stop and disable service if running
if [ -d /run/systemd/system ]; then
if systemctl is-active --quiet mond.service; then
echo "Stopping mond service..."
systemctl stop mond.service
fi
if systemctl is-enabled --quiet mond.service 2>/dev/null; then
echo "Disabling mond service..."
systemctl disable mond.service
fi
fi
case "$1" in
upgrade)
# 升级时只停止服务,保留 enabled 状态
if [ -d /run/systemd/system ]; then
if systemctl is-active --quiet mond.service; then
echo "Stopping mond service for upgrade..."
systemctl stop mond.service
fi
fi
;;
remove|deconfigure)
# 删除时停止并禁用服务
if [ -d /run/systemd/system ]; then
if systemctl is-active --quiet mond.service; then
echo "Stopping mond service..."
systemctl stop mond.service
fi
if systemctl is-enabled --quiet mond.service 2>/dev/null; then
echo "Disabling mond service..."
systemctl disable mond.service
fi
fi
;;
failed-upgrade)
# 升级失败时不做操作
;;
*)
echo "prerm called with unknown argument \`$1'" >&2
exit 1
;;
esac
exit 0