#!/bin/sh
# Runs before the package is removed. Stop any running instances cleanly so
# the files we're about to delete aren't held open.
set -e

case "$1" in
    remove|upgrade|deconfigure)
        if [ -d /run/systemd/system ]; then
            for unit in nginx-logtail-collector.service nginx-logtail-aggregator.service nginx-logtail-frontend.service; do
                systemctl stop "$unit" 2>/dev/null || true
            done
        fi
        ;;
esac

#DEBHELPER#
exit 0
