#!/bin/sh

set -e

if [ "$1" = configure ] && [ -z "$2" ] && bootctl --print-esp-path > /dev/null 2>&1; then
    bootctl install --make-machine-id-directory=auto

    # register existing kernel(s)
    for k in /boot/vmlinuz-* ; do
        [ -f "$k" ] || continue
        ver=$(basename "$k" | sed s/^vmlinuz-//)
        kernel-install add "$ver" "$k"
    done
fi

if [ "$1" = configure ] && [ -n "$2" ] && bootctl is-installed > /dev/null 2>&1; then
    bootctl update --graceful
fi

# Automatically added by dh_installdeb/13.11.4
dpkg-maintscript-helper mv_conffile /etc/kernel/postinst.d/systemd-boot /etc/kernel/postinst.d/zz-systemd-boot 251.4-4\~ -- "$@"
dpkg-maintscript-helper mv_conffile /etc/kernel/postrm.d/systemd-boot /etc/kernel/postrm.d/zz-systemd-boot 251.4-4\~ -- "$@"
# End automatically added section

