#!/bin/sh

set -e


remove_apt_auth(){
    # config file created at runtime, needs explicit handling on purge
    rm -f /etc/apt/auth.conf.d/90ubuntu-advantage
}

remove_cache_dir(){
    rm -rf /var/lib/ubuntu-advantage
}

remove_logs(){
    rm -f /var/log/ubuntu-advantage.log*
}

remove_esm(){
    # config files created in postinst, need explicit handling on purge
    rm -f /etc/apt/trusted.gpg.d/ubuntu-advantage-esm-infra-trusty.gpg
    rm -f /etc/apt/trusted.gpg.d/ubuntu-advantage-esm-infra-legacy-trusty.gpg
    rm -f /etc/apt/sources.list.d/ubuntu-esm-infra-trusty.list
    rm -f /etc/apt/sources.list.d/ubuntu-esm-infra-legacy-trusty.list
    rm -f /etc/apt/preferences.d/ubuntu-esm-infra-trusty
}

case "$1" in
    purge)
        remove_apt_auth
        remove_cache_dir
        remove_logs
        remove_esm
        ;;
esac

#DEBHELPER#

exit 0
