#!/bin/sh

set -e

if [ "$1" = 'purge' ]; then
	echo You may want to delete the generated stunnel.pem file
	echo in /etc/ssl/certs.

	# Remove chroot dir if present. It may contain logfiles
	rm -rf /var/lib/stunnel4 || true

	# Log files must be removed on purge (Policy 10.8)
	rm -f /var/log/stunnel4/stunnel.log* || true
	rmdir /var/log/stunnel4 || true
fi

# Automatically added by dh_installinit/13.11.4
if [ "$1" = "remove" ] && [ -x "/etc/init.d/stunnel4" ] ; then
	chmod -x "/etc/init.d/stunnel4" >/dev/null || true
fi
if [ -z "${DPKG_ROOT:-}" ] && [ "$1" = "purge" ] ; then
	update-rc.d stunnel4 remove >/dev/null
fi
# End automatically added section
# Automatically added by dh_installsystemd/13.11.4
if [ "$1" = remove ] && [ -d /run/systemd/system ] ; then
	systemctl --system daemon-reload >/dev/null || true
fi
# End automatically added section
# Automatically added by dh_installsystemd/13.11.4
if [ "$1" = "purge" ]; then
	if [ -x "/usr/bin/deb-systemd-helper" ]; then
		deb-systemd-helper purge 'stunnel.target' >/dev/null || true
	fi
fi
# End automatically added section

