#!/bin/sh
# prerm — stop running KylinBot daemons before remove/upgrade so the new
# binary isn't shadowed by a stale process. The XDG autostart entry will
# bring the daemon back on next login (or immediately via postinst on upgrade).
set -e

BIN=/usr/bin/kylin-bot

case "$1" in
    remove|upgrade|deconfigure)
        # Best-effort: never fail the removal if no daemon is running.
        pkill -f "$BIN daemon" 2>/dev/null || true
        ;;
    failed-upgrade)
        ;;
esac

#DEBHELPER#

exit 0
