#!/bin/sh
# Cleanup script for Gandi records, as Debian preinst

set -eu -o errexit

# Source debconf shell library
if [ -f /usr/share/debconf/confmodule ]; then
    . /usr/share/debconf/confmodule
fi

case "$1" in
    upgrade)
        # If we are upgrading from 1.2.5-3, then we need to rewrite the
        # configuration files. Otherwise, we do nothing.
        if [ "$2" = "1.2.5-3" ]; then
            sed -i -- 's/certbot-plugin-gandi:dns/dns-gandi/g' /etc/letsencrypt/renewal/*.conf
        fi
        ;;

    install | abort-upgrade)
        # Expected, but unimplemented options
        ;;

    *)
        printf "preinst called with unknown argument \'%b'" "$1" >&2
        exit 1
        ;;
esac

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

#DEBHELPER#

exit 0
