The code could be added to /etc/kernel/postinst.d/zz-update-grub, too, to avoid unnecessarily updating grub.
The code could be added to /etc/kernel/ postinst. d/zz-update- grub, too, to avoid unnecessarily updating grub.