#!/bin/sh

set -e

#DEBHELPER#

case "$1" in
    configure)
        # Check if we are in a chroot environment
        # Alternatively use: systemd-detect-virt --chroot
        if ! ischroot; then
            # Update module dependencies
            depmod

            # Update initramfs
            if which update-initramfs >/dev/null ; then
		        echo "Updating initramfs. Please wait."
		        update-initramfs -v -u -k $(uname -r)
	        fi

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

    abort-upgrade|abort-remove|abort-deconfigure)
        # Check if we are in a chroot environment
        # Alternatively use: systemd-detect-virt --chroot
        if ! ischroot; then
            # Update module dependencies
            depmod

            # Update initramfs
            if which update-initramfs >/dev/null ; then
		        echo "Updating initramfs. Please wait."
		        update-initramfs -u -k $(uname -r)
	        fi
        fi
    ;;

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

exit 0

