#! /bin/sh
# postrm script for buildd
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postrm> `remove'
#        * <postrm> `purge'
#        * <old-postrm> `upgrade' <new-version>
#        * <new-postrm> `failed-upgrade' <old-version>
#        * <new-postrm> `abort-install'
#        * <new-postrm> `abort-install' <old-version>
#        * <new-postrm> `abort-upgrade' <old-version>
#        * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
# for details, see /usr/share/doc/packaging-manual/

if which dpkg-maintscript-helper >/dev/null
then
    # No predepends possible because Lenny needs to be supported.
    dpkg-maintscript-helper rm_conffile /etc/schroot/script-defaults.buildd -- "$@"
    dpkg-maintscript-helper rm_conffile /etc/schroot/mount-defaults.buildd -- "$@"
    dpkg-maintscript-helper rm_conffile /etc/schroot/setup.d/25nssdatabases -- "$@"
fi

case "$1" in

    remove|upgrade|failed-upgrade|abort-install|abort-upgrade)

        ;;

    purge|disappear)

	# Lock buildd account.
	usermod -L -e 1 buildd || true

        ;;

    *)

        echo "postrm called with unknown argument \`$1'" >&2
        exit 0

	;;
esac

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

# Automatically added by dh_installinit
if [ "$1" = "purge" ] ; then
	update-rc.d buildd remove >/dev/null
fi


# In case this system is running systemd, we make systemd reload the unit files
# to pick up changes.
if [ -d /run/systemd/system ] ; then
	systemctl --system daemon-reload >/dev/null || true
fi
# End automatically added section


exit 0
