#!/bin/sh
# postinst script
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

PACKAGE=caracalla-meta
case "$1" in
    configure)
        #By default, the network-manager is the network service for caracalla
        #Disable the systemd-networkd-wait-online.service to prevent boot time wait too long issue
        if [ -e /etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service ] && [ -e /etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service ]; then
            rm /etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service
        fi

        CONFIG="/etc/apt/apt.conf.d/20auto-upgrades"
        # now, platform-meta would not take over the 20auto-upgrades
        # it would use another config file to override the configs
        ucfr --purge $PACKAGE $CONFIG 2>/dev/null || true

        CONFIG="/etc/apt/apt.conf.d/50unattended-upgrades"
        # now, platform-meta would not take over the 50unattended-upgrades
        ucfr --purge $PACKAGE $CONFIG 2>/dev/null || true
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

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

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0
