fix: 修复 apt 升级后服务需要手动重新启用的问题

- 修改 prerm 脚本,升级时只停止服务不禁用
- 修改 postinst 脚本,升级后自动重启已启用的服务
- 首次安装仍保持手动启用服务的行为
This commit is contained in:
2026-01-23 11:35:32 +08:00
parent b4a284efd1
commit 8f0463687e
2 changed files with 58 additions and 23 deletions

48
debian/prerm vendored
View File

@@ -1,17 +1,33 @@
#!/bin/sh
set -e
case "$1" in
upgrade)
# Stop service only during upgrade, keep enabled state
if [ -d /run/systemd/system ]; then
if systemctl is-active --quiet p2pool.service; then
echo "Stopping p2pool service for upgrade..."
systemctl stop p2pool.service
fi
fi
;;
remove|deconfigure)
# Stop and disable service during removal
if [ -d /run/systemd/system ]; then
if systemctl is-active --quiet p2pool.service; then
echo "Stopping p2pool service..."
systemctl stop p2pool.service
fi
if systemctl is-enabled --quiet p2pool.service 2>/dev/null; then
echo "Disabling p2pool service..."
systemctl disable p2pool.service
fi
fi
;;
failed-upgrade)
# Do nothing on failed upgrade
;;
*)
echo "prerm called with unknown argument \`$1'" >&2
exit 1
;;
esac
# Stop and disable service if running
if [ -d /run/systemd/system ]; then
if systemctl is-active --quiet p2pool.service; then
echo "Stopping p2pool service..."
systemctl stop p2pool.service
fi
if systemctl is-enabled --quiet p2pool.service 2>/dev/null; then
echo "Disabling p2pool service..."
systemctl disable p2pool.service
fi
fi
exit 0
exit 0