#!/bin/bash

set -e

if dpkg-maintscript-helper supports rm_conffile; then
	dpkg-maintscript-helper rm_conffile \
		/etc/logrotate.d/atop 1.26-2~ -- "$@"
fi

case "$1" in
    configure)
        touch /var/log/atop/dummy_after /var/log/atop/dummy_before
        if dpkg --compare-versions "$2" lt-nl 2; then
            # updating from a pre-2.0 version which won't read the old log file format
            # move away old log file format
            DATE="$(date +%Y%m%d)"
            if [ -e "/var/log/atop/atop_${DATE}" ]; then
                mv "/var/log/atop/atop_${DATE}" "/var/log/atop/atop_${DATE}_pre_2_0"
            fi
        fi
        ;;
esac

#DEBHELPER#
