#!/bin/bash
# postrm for smartbotic-automation
set -e

SM_USER="smartbotic-automation"
SM_GROUP="smartbotic-automation"

case "$1" in
    purge)
        rm -rf /var/lib/smartbotic-automation /var/log/smartbotic-automation /etc/smartbotic-automation
        if getent passwd "$SM_USER" >/dev/null 2>&1; then
            deluser --system "$SM_USER" >/dev/null 2>&1 || true
        fi
        if getent group "$SM_GROUP" >/dev/null 2>&1; then
            delgroup --system "$SM_GROUP" >/dev/null 2>&1 || true
        fi
        ;;
    remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
        if [ -d /run/systemd/system ]; then
            systemctl daemon-reload >/dev/null 2>&1 || true
        fi
        ;;
esac

exit 0
