#!/bin/sh
set -e

case "$1" in
    remove)
        if [ -d /run/systemd/system ]; then
            # On running systems, stop and disable the units.
            systemctl disable --now incus-startup.service
            systemctl disable --now incus-user.service incus-user.socket
            systemctl disable --now incus.service incus.socket
            systemctl disable --now incus-lxcfs.service
        elif command -v systemctl >/dev/null 2>&1; then
            # On non-running systems, just disable the units.
            systemctl disable incus-startup.service
            systemctl disable incus-user.service incus-user.socket
            systemctl disable incus.service incus.socket
            systemctl disable incus-lxcfs.service
        else
            echo "Skipping systemd unit disabling as systemd couldn't be found"
        fi
    ;;

    upgrade|deconfigure|failed-upgrade)
    ;;

    *)
        echo "prerm called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac



exit 0
