#!/bin/sh
set -e

# 仅在卸载(remove)时停用服务；升级(upgrade)时保持运行，
# 由 postinst 的 try-restart 重启以加载新二进制
if [ "$1" = "remove" ] && [ -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

exit 0
