#!/bin/sh

set -e

rm_if_matches_md5sum() {
    F="$1"
    M="$2"
    if [ -e "$F" ]; then
        md5=$(md5sum "$F" | cut -f 1 -d\ )
        if [ "$md5" = "$M" ]; then
	    rm "$F"
        fi
    fi
}


case "$1" in
  install|upgrade)
      # older versions did not ship /etc/os-release as a conffile but
      # newer do, because the content changed this triggers a conffile prompt
      # now. by removing the file (if unmodified) we avoid this prompt and
      # dpkg will re-create it
      if dpkg --compare-versions "$2" le-nl "6.5ubuntu11"; then
          rm_if_matches_md5sum "/etc/os-release" f8186963c93529f30f62095d35d44138
          rm_if_matches_md5sum "/etc/os-release" f528f92199aadbee067e3a24d4b1077a
          rm_if_matches_md5sum "/etc/os-release" 0cacc849efc99ac03921a892ca9e0db1
      fi
  ;;
esac

dpkg-maintscript-helper rm_conffile /etc/update-motd.d/99-footer 7.2ubuntu2~ -- "$@"
