#!/bin/sh

set -e

#DEBHELPER#

case "$1" in
    remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
        # Check if we are in a chroot environment
        # Alternatively use: systemd-detect-virt --chroot
        if ! ischroot; then    
            # Update initramfs
            if which update-initramfs >/dev/null ; then
		        echo "Updating initramfs. Please wait."
		        update-initramfs -v -u -k $(uname -r)
	        fi

            # Update module dependencies
            depmod

            echo "Please reboot your system to unload the Realtek r8126 driver."
        fi
    ;;

    purge)
        # No specific actions needed on purge
    ;;

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

exit 0
