add_updategrub-service installs a small systemd shutdown integration that performs a complete GRUB configuration regeneration before shutdown, reboot, or halt.
The project addresses the gap between snapshot creation and the next boot. Snapshot watchers or package-manager hooks may refresh GRUB at other times, but this service provides a final distribution-neutral regeneration at the shutdown boundary.
add_updategrub-service.sh
|
+-- installs /opt/snapper/bin/update-grub-shutdown.sh
|
+-- installs /etc/systemd/system/updategrub-shutdown.service
|
+-- reloads systemd and enables the service
The helper executes:
grub-mkconfig -o /boot/grub/grub.cfgThe service is a Type=oneshot unit ordered before shutdown.target, reboot.target, and halt.target and enabled by those targets.
The installer must run as a normal user. It requests sudo only for operations that modify system locations or systemd state.
Installation is repeatable:
- Create
/opt/snapper/binwhen needed. - Replace the installed helper with the current embedded version.
- Replace the systemd unit with the current definition.
- Reload the systemd manager.
- Enable the unit.
- Verify that the unit is enabled.
No background process is started by the installer. The oneshot helper runs only through the shutdown, reboot, or halt targets.
Version 1.0.1 uses grub-mkconfig directly instead of the Debian-specific update-grub wrapper. The output remains /boot/grub/grub.cfg, which is the layout validated by this project.
Testing covers Debian, Ubuntu, Kubuntu, and CachyOS, representing Debian/Ubuntu-based and Arch-based systems. Version 1.0.1 was specifically regression-tested on Debian and CachyOS after the command change.
The tested CachyOS system also had an active grub-btrfsd service and a Pacman GRUB hook. The shutdown service installed and operated successfully alongside both.
Both the installer and generated helper use strict shell error handling. A failed grub-mkconfig invocation causes the oneshot service to fail instead of reporting a successful update.
The installer verifies that the unit is enabled and exits nonzero if enablement fails.
add_updategrub-service/
├── ARCHITECTURE.md
├── README.md
└── add_updategrub-service.sh
The source file declares GPL-3.0-or-later.