#!/bin/sh
set -e;

PACKAGE=sendmail-bin;

if [ "$1" = "remove" ]; then
		# Remove alternatives for MTA, MSP
		update-alternatives --remove sendmail-mta @libexecdir@/sendmail;
		update-alternatives --remove sendmail-msp @libexecdir@/sendmail;
		if [ -x @sysconfdir@/init.d/sendmail ] && \
			[ -x @datadir@/sendmail/sendmail ]; then
			invoke-rc.d --quiet --force sendmail stop
			fi;
		# Prevent cronjob from running during upgrade...
		if [ -f /etc/cron.d/sendmail ]; then
			rm -f @sysconfdir@/cron.d/sendmail;
			fi;
fi

if [ "$1" = "upgrade" ]; then
		# Prevent cronjob from running during upgrade...
		if [ -f /etc/cron.d/sendmail ]; then
			echo "#prerm" > @sysconfdir@/cron.d/sendmail;
			fi;

		# NOTE  NOTE  NOTE  NOTE  NOTE
		# If we fall through to DEBHELPER, sendmail will be stopped
		# much earlier than necessary !!!
		exit 0;
fi

#DEBHELPER#
