-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support early/late hooks in generate-zbm
Since generate-zbm only knows how to manage one ESP, it can be a challenge to keep multiple redundant ESPs up-to-date on a system. To help with this, Global.PreHooksDir and Global.PostHooksDir can now be defined to point to a directory of executable hooks. These are executed without any additional environment context or arguments.
- Loading branch information
Showing
5 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
|
||
cleanup() { | ||
if [ -n "${ESP_MNT}" ]; then | ||
mountpoint -q "${ESP_MNT}" && umount -R "${ESP_MNT}" | ||
[ -d "${ESP_MNT}" ] && rmdir "${ESP_MNT}" | ||
fi | ||
} | ||
|
||
ESPS=( | ||
"/dev/sdb1" | ||
"/dev/sdc1" | ||
"/dev/sdd1" | ||
) | ||
|
||
BMP="$( yq-go eval ".Global.BootMountPoint" /etc/zfsbootmenu/config.yaml )" | ||
if [ -z "${BMP}" ]; then | ||
echo "Unable to determine BootMountPoint" | ||
exit 1 | ||
fi | ||
|
||
IMG_DIR="$( yq-go eval ".EFI.ImageDir" /etc/zfsbootmenu/config.yaml )" | ||
if [ -z "${IMG_DIR}" ]; then | ||
echo "Unable to determine ImageDir" | ||
exit 1 | ||
fi | ||
|
||
IMG_REL="${IMG_DIR#"${BMP}"}" | ||
|
||
mount "${BMP}" | ||
|
||
if ! ESP_MNT="$( mktemp -d )"; then | ||
echo "Unable to create temporary mountpoint" | ||
exit | ||
fi | ||
|
||
trap cleanup EXIT INT TERM | ||
|
||
for ESP in "${ESPS[@]}"; do | ||
if ! mount "${ESP}" "${ESP_MNT}" ; then | ||
echo "Unable to mount ${ESP} at ${ESP_MNT}" | ||
continue | ||
fi | ||
|
||
mkdir -p "${ESP_MNT}${IMG_REL}" | ||
rsync --delete-after -avpP --include=zfsbootmenu\* --exclude=\* "${IMG_DIR}/" "${ESP_MNT}${IMG_REL}/" | ||
|
||
if ! umount "${ESP_MNT}" ; then | ||
echo "Unable to unmount ${ESP_MNT}" | ||
exit 1 | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters