#! /bin/sh
# config script for collectd
#
# see: dh_installdebconf(1)

set -e

# summary of how this script can be called:
#        * <preconfigure> `configure' <installed-version>
#        * <postinst> `configure' <old-version>
#        * <reconfigure> `reconfigure' <installed-version>

. /usr/share/debconf/confmodule

case "$1" in
    configure)
        db_set collectd/auto-migrate-3-4 false

        if dpkg --compare-versions "$2" lt-nl "4.0.0~"; then
            if perl -e '1' 2> /dev/null && rrdtool > /dev/null 2>&1; then
                db_input high collectd/auto-migrate-3-4 || true
                db_go || true
            else
                db_input high collectd/migration-3-4 || true
                db_go || true
            fi
        fi
    ;;

    reconfigure)
    ;;

    *)
        echo "config called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

db_stop

exit 0

