mirror of
https://github.com/Antynea/grub-btrfs.git
synced 2026-08-23 08:43:33 +08:00
Compare commits
9 Commits
v4.14
...
5b567255e3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b567255e3 | ||
|
|
a181e2ca41 | ||
|
|
a79c9cc42c | ||
|
|
88e8b4ae97 | ||
|
|
004fe0aae4 | ||
|
|
828f593f6f | ||
|
|
b8e6deaafd | ||
|
|
7e8a45ca9c | ||
|
|
14fa71c994 |
34
.github/workflows/bump-version-on-merge.yml
vendored
Normal file
34
.github/workflows/bump-version-on-merge.yml
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
name: Bump version on merge
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
bump-version:
|
||||
name: Bump version in config
|
||||
runs-on: ubuntu-latest
|
||||
if: github.actor != 'github-actions[bot]'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: master
|
||||
fetch-tags: true
|
||||
|
||||
- name: Update version in config
|
||||
run: |
|
||||
version="$(git describe --tags --abbrev=0)-$(git rev-parse --abbrev-ref HEAD)-$(date -u -Iseconds)"
|
||||
sed -i "s/GRUB_BTRFS_VERSION=.*/GRUB_BTRFS_VERSION=${version}/" config
|
||||
|
||||
- name: Commit updated config
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add config
|
||||
git commit -m "chore: bump version to ${version}"
|
||||
git push origin master
|
||||
33
.github/workflows/bump-version.yml
vendored
Normal file
33
.github/workflows/bump-version.yml
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
name: Bump version on tag
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
bump-version:
|
||||
name: Bump version in config
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: master
|
||||
fetch-tags: true
|
||||
|
||||
- name: Update version in config
|
||||
run: |
|
||||
version="$(git describe --tags --abbrev=0)"
|
||||
sed -i "s/GRUB_BTRFS_VERSION=.*/GRUB_BTRFS_VERSION=${version}/" config
|
||||
|
||||
- name: Commit updated config
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add config
|
||||
git commit -m "chore: bump version to ${version}"
|
||||
git push origin master
|
||||
@@ -107,38 +107,84 @@ esac
|
||||
if [ -n "${GRUB_BTRFS_PROTECTION_AUTHORIZED_USERS}" ] ; then
|
||||
protection_authorized_users="--users ${GRUB_BTRFS_PROTECTION_AUTHORIZED_USERS} "
|
||||
fi
|
||||
|
||||
## Probe information of Root and Boot devices
|
||||
# Probe info "Root partition"
|
||||
root_device=$(${grub_probe} --target=device /) # Root device
|
||||
root_uuid=$(${grub_probe} --device ${root_device} --target="fs_uuid" 2>/dev/null) # UUID of the root device
|
||||
root_uuid_subvolume=$(btrfs subvolume show / 2>/dev/null) || print_error "UUID of the root subvolume is not available"; # If UUID of root subvolume is not available, then exit
|
||||
root_uuid_subvolume=$(awk -F":" 'match($1, /(^[ \t]+UUID)/) {sub(/^[ \t]+/, "", $2); print $2}' <<< "$root_uuid_subvolume") # UUID of the root subvolume '
|
||||
# Probe info "Boot partition"
|
||||
boot_device=$(${grub_probe} --target=device ${boot_directory}) # Boot device
|
||||
boot_uuid=$(${grub_probe} --device ${boot_device} --target="fs_uuid" 2>/dev/null) # UUID of the boot device
|
||||
boot_uuid_subvolume=$(btrfs subvolume show "$boot_directory" 2>/dev/null) || boot_uuid_subvolume=" UUID: $root_uuid_subvolume"; # If boot folder isn't a subvolume, then UUID=root_uuid_subvolume
|
||||
boot_uuid_subvolume=$(awk -F":" 'match($1, /(^[ \t]+UUID)/) {sub(/^[ \t]+/, "", $2); print $2}' <<< "$boot_uuid_subvolume") # UUID of the boot subvolume '
|
||||
boot_hs=$(${grub_probe} --device ${boot_device} --target="hints_string" 2>/dev/null) # hints string
|
||||
boot_fs=$(${grub_probe} --device ${boot_device} --target="fs" 2>/dev/null) # Type filesystem of boot device
|
||||
# -----------------------------------------------------------
|
||||
|
||||
# Enable LUKS encrypted devices support
|
||||
# ---------- Root partition ----------
|
||||
root_device="$(${grub_probe} --target=device /)" # e.g. /dev/mapper/enc
|
||||
root_uuid="$(${grub_probe} --device "${root_device}" --target=fs_uuid 2>/dev/null)" || true
|
||||
|
||||
# Fallback when grub-probe fails (encrypted container, detached header…)
|
||||
if [ -z "$root_uuid" ]; then
|
||||
root_uuid="$(blkid -s UUID -o value "${root_device}" 2>/dev/null)"
|
||||
fi
|
||||
[ -z "$root_uuid" ] && print_error "Cannot determine UUID of ${root_device}"
|
||||
|
||||
# Root subvolume UUID
|
||||
root_uuid_subvolume="$(btrfs subvolume show / 2>/dev/null | \
|
||||
awk -F':' '/^\s*UUID/ {gsub(/^[ \t]+/, "", $2); print $2}')"
|
||||
[ -z "$root_uuid_subvolume" ] && print_error "UUID of the root subvolume is not available"
|
||||
|
||||
# ---------- Boot partition ----------
|
||||
boot_device="$(${grub_probe} --target=device "${boot_directory}")" # e.g. /dev/sdb1
|
||||
boot_uuid="$(${grub_probe} --device "${boot_device}" --target=fs_uuid 2>/dev/null)" || true
|
||||
|
||||
# Fallback for boot UUID
|
||||
if [ -z "$boot_uuid" ]; then
|
||||
boot_uuid="$(blkid -s UUID -o value "${boot_device}" 2>/dev/null)"
|
||||
fi
|
||||
[ -z "$boot_uuid" ] && print_error "Cannot determine UUID of ${boot_device}"
|
||||
|
||||
# If /boot is not a Btrfs subvolume, reuse root subvol UUID
|
||||
boot_uuid_subvolume="$(
|
||||
btrfs subvolume show "${boot_directory}" 2>/dev/null | \
|
||||
awk -F':' '/^\s*UUID/ {gsub(/^[ \t]+/, "", $2); print $2; exit}'
|
||||
)"
|
||||
[ -z "$boot_uuid_subvolume" ] && boot_uuid_subvolume="$root_uuid_subvolume"
|
||||
|
||||
# Extra data for GRUB commands
|
||||
boot_hs="$(${grub_probe} --device "${boot_device}" --target=hints_string 2>/dev/null)"
|
||||
boot_fs="$(${grub_probe} --device "${boot_device}" --target=fs 2>/dev/null)"
|
||||
# -----------------------------------------------------------
|
||||
|
||||
## Enable LUKS encrypted devices support
|
||||
case "$(echo "$GRUB_BTRFS_ENABLE_CRYPTODISK" | tr '[:upper:]' '[:lower:]')" in
|
||||
true)
|
||||
list_insmods=()
|
||||
list_insmods+=("insmod gzio")
|
||||
list_insmods+=("insmod part_gpt")
|
||||
list_insmods+=("insmod cryptodisk")
|
||||
list_insmods+=("insmod luks")
|
||||
list_insmods+=("insmod gcry_rijndael")
|
||||
list_insmods+=("insmod gcry_rijndael")
|
||||
list_insmods+=("insmod gcry_sha256")
|
||||
list_insmods+=("insmod ${boot_fs}")
|
||||
list_insmods+=("cryptomount -u $(echo $GRUB_CMDLINE_LINUX_DEFAULT | grep -o -P '(?<=cryptdevice=UUID=).*(?=:cryptdev)')")
|
||||
;;
|
||||
list_insmods=(
|
||||
"insmod gzio"
|
||||
"insmod part_gpt"
|
||||
"insmod cryptodisk"
|
||||
"insmod luks"
|
||||
"insmod gcry_rijndael"
|
||||
"insmod gcry_rijndael"
|
||||
"insmod gcry_sha256"
|
||||
"insmod ${boot_fs}"
|
||||
)
|
||||
|
||||
# Extract the <source> field of cryptdevice=<source>:<name>[:header]
|
||||
crypt_source="$(printf '%s %s\n' "$GRUB_CMDLINE_LINUX_DEFAULT" "$GRUB_CMDLINE_LINUX" \
|
||||
| grep -o -P 'cryptdevice=\K[^:]+' || true)"
|
||||
|
||||
# Turn the source into a UUID that cryptomount -u understands
|
||||
crypt_uuid=""
|
||||
if [[ "$crypt_source" =~ ^UUID=.* ]]; then # already UUID=…
|
||||
crypt_uuid="${crypt_source#UUID=}"
|
||||
elif [[ "$crypt_source" == /dev/* ]]; then # path → resolve → blkid
|
||||
real_dev=$(readlink -f "$crypt_source" 2>/dev/null || true)
|
||||
[ -b "$real_dev" ] && crypt_uuid=$(blkid -s UUID -o value "$real_dev" 2>/dev/null || true)
|
||||
fi
|
||||
|
||||
# Emit the proper cryptomount command
|
||||
if [[ "$crypt_uuid" =~ ^[0-9a-fA-F-]{36}$ ]]; then
|
||||
list_insmods+=("cryptomount -u ${crypt_uuid}")
|
||||
else
|
||||
# last-resort: scan all crypto containers (works but a bit slower)
|
||||
list_insmods+=("cryptomount -a")
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
list_insmods=("insmod ${boot_fs}")
|
||||
;;
|
||||
list_insmods=("insmod ${boot_fs}")
|
||||
;;
|
||||
esac
|
||||
|
||||
## Parameters passed to the kernel
|
||||
@@ -351,7 +397,7 @@ snapshot_list()
|
||||
# Parse Snapper & timeshift & yabsnap information
|
||||
local type_snapshot="N/A"
|
||||
local description_snapshot="N/A"
|
||||
|
||||
|
||||
# path to yabsnap snapshot meta data
|
||||
local yabsnap_info="$grub_btrfs_mount_point/${path_snapshot%"/"*}/$(echo "${snap[13]}" | awk -F'/' '{print $3 "-meta.json"}')"
|
||||
|
||||
|
||||
10
config
10
config
@@ -1,7 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
GRUB_BTRFS_VERSION=4.13-yabsnap_info_support-2024-03-06T13:43:57+00:00
|
||||
GRUB_BTRFS_VERSION=-master-2026-05-10T10:13:56+00:00
|
||||
|
||||
# Distribution specific auto-detection (e.g. Fedora)
|
||||
if [ -f /etc/fedora-release ]; then
|
||||
GRUB_BTRFS_GRUB_DIRNAME="/boot/grub2"
|
||||
GRUB_BTRFS_GBTRFS_DIRNAME="/boot/grub2"
|
||||
GRUB_BTRFS_MKCONFIG="grub2-mkconfig"
|
||||
GRUB_BTRFS_SCRIPT_CHECK="grub2-script-check"
|
||||
fi
|
||||
|
||||
# Disable grub-btrfs.
|
||||
# Default: "false"
|
||||
|
||||
Reference in New Issue
Block a user