#!/bin/bash

## Copyright (C) 2025 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

set -e

true "
#####################################################################
## INFO: BEGIN: $DPKG_MAINTSCRIPT_PACKAGE $DPKG_MAINTSCRIPT_NAME $@
#####################################################################
"

if [ "$1" = 'remove' ]; then
   true "INFO: Fixing autologin if needed."
   /usr/libexec/user-sysmaint-split/sysmaint-boot cleanup-autologin
   true "INFO: Done fixing autologin if needed."
   true "INFO: Disabling sysmaint-related systemd services."
   deb-systemd-helper disable sysmaint-boot.service
   deb-systemd-helper disable sysmaint-boot-cleanup.service
   deb-systemd-helper disable sysmaint-boot-unrestricted-qubes.service
   deb-systemd-helper purge sysmaint-boot.service
   deb-systemd-helper purge sysmaint-boot-cleanup.service
   deb-systemd-helper purge sysmaint-boot-unrestricted-qubes.service
   true "INFO: Done disabling sysmaint-related systemd services."
fi

true "INFO: debhelper beginning here."

#DEBHELPER#

true "INFO: Done with debhelper."

true "
#####################################################################
## INFO: END  : $DPKG_MAINTSCRIPT_PACKAGE $DPKG_MAINTSCRIPT_NAME $@
#####################################################################
"

## Explicitly "exit 0", so eventually trapped errors can be ignored.
exit 0
