3e90b9
#!/usr/bin/bash
3e90b9
3e90b9
if ! [[ $KERNEL_INSTALL_MACHINE_ID ]]; then
3e90b9
    exit 0
3e90b9
fi
3e90b9
3e90b9
COMMAND="$1"
3e90b9
KERNEL_VERSION="$2"
3e90b9
BOOT_DIR_ABS="$3"
3e90b9
3e90b9
# If $BOOT_DIR_ABS exists, some other boot loader is active.
3e90b9
[[ -d "$BOOT_DIR_ABS" ]] && exit 0
3e90b9
3e90b9
run_hooks()
3e90b9
{
3e90b9
    local f
3e90b9
    local files="$1"
3e90b9
    for f in $files ; do
3e90b9
        [ -x "$f" ] || continue
3e90b9
        "$f" "$KERNEL_VERSION" "/boot/vmlinuz-$KERNEL_VERSION"
3e90b9
    done
3e90b9
}
3e90b9
3e90b9
case "$COMMAND" in
3e90b9
    add)
3e90b9
        run_hooks "/etc/kernel/postinst.d/*[^~] /etc/kernel/postinst.d/$KERNEL_VERSION/*[^~]"
3e90b9
        ;;
3e90b9
    remove)
3e90b9
        run_hooks "/etc/kernel/prerm.d/*[^~] /etc/kernel/prerm.d/$KERNEL_VERSION/*[^~]"
3e90b9
        ;;
3e90b9
    *)
3e90b9
        exit 0
3e90b9
esac