#!/bin/sh
# postrm script for fliwi-apt-cacher-ng-config
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postrm> `remove'
#        * <postrm> `purge'
#        * <old-postrm> `upgrade' <new-version>
#        * <new-postrm> `failed-upgrade' <old-version>
#        * <new-postrm> `abort-install'
#        * <new-postrm> `abort-install' <old-version>
#        * <new-postrm> `abort-upgrade' <old-version>
#        * <disappearer's-postrm> `disappear' <overwriter>
#          <overwriter-version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

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

#DEBHELPER#

apt_cacher_dir="/etc/apt-cacher-ng"
fliwi_apt_cacher_opts_file="$apt_cacher_dir/fliwi-apt-cacher-opts.conf"

case "$1" in
  remove|purge|disappear)
    # remove the file which was created in postinst
    rm -f $fliwi_apt_cacher_opts_file || true

    # check for links we automatically created, and remove them
    for file in $(find $apt_cacher_dir -maxdepth 1 -type l -name "*_fliwiautolink.conf"); do
      rm -f $file
    done
  ;;

  upgrade|failed-upgrade|abort-install|abort-upgrade)
  ;;

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

exit 0


