#!/bin/sh
set -e

if ([ "$1" = remove ] || [ "$1" = purge ]) ; then
    if [ -x "$(command -v systemd-detect-virt 2>/dev/null)" ] ; then
        systemd-detect-virt --quiet --container && is_running_in_container=true
    fi

    if [ -e /boot/grub/grub.cfg ] && [ -x "$(command -v update-grub2 2>/dev/null)" ] &&
        [ "x$is_running_in_container" != "xtrue" ] ; then
        update-grub
    fi
fi


