#!/bin/bash



error()
{
    RET=$?
    MSG=$1
    echo "E: $MSG";
    exit $RET
}

if which plymouth-set-default-theme >/dev/null 2>&1; then
	plymouth-set-default-theme -R Fallout
fi

case "$1" in
    configure)
        update-alternatives \
            --install /usr/share/plymouth/themes/default.plymouth default.plymouth \
                /usr/share/plymouth/themes/Fallout/Fallout.plymouth 160 || error "Failed to update-alternatives"

plymouth-set-default-theme -R Fallout
if which update-initramfs >/dev/null 2>&1
then
    update-initramfs -u
fi
if which grub-mkconfig >/dev/null 2>&1;	then
    grub-mkconfig -o /boot/grub/grub.cfg
fi

        if which update-initramfs >/dev/null 2>&1; then
            update-initramfs -u || error "Failed to update-initramfs"
        fi

        if [ -e /boot/grub/grub.cfg ] && which grub-mkconfig >/dev/null 2>&1; then
            grub-mkconfig -o /boot/grub/grub.cfg || error "Failed to update-grub2"
        fi
        ;;

    abort-upgrade|abort-deconfigure|abort-remove)
        ;;

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

post_install() {
	if which update-initramfs >/dev/null 2>&1
	then
	    update-initramfs -u
	fi
	if which grub-mkconfig >/dev/null 2>&1;	then
	    grub-mkconfig -o /boot/grub/grub.cfg
	fi
}
post_upgrade() {
plymouth-set-default-theme -R Fallout
post_install
}
exit 0
