#!/bin/sh
set -e

if [ "$1" = "remove" ]; then
	# Prevent cronjob from running during removal...
	if [ -f @sysconfdir@/cron.d/sendmail ]; then
		rm -f @sysconfdir@/cron.d/sendmail
	fi
fi

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

#DEBHELPER#

if [ "$1" = "remove" ]; then
	# Remove alternatives for MTA, MSP
	# Note: removes paths needed by the initscript
	update-alternatives --remove sendmail-mta @libexecdir@/sendmail
	update-alternatives --remove sendmail-msp @libexecdir@/sendmail
fi
