mirror of
https://github.com/Antynea/grub-btrfs.git
synced 2026-03-10 00:05:32 +08:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5fe28d39be | ||
|
|
5e8c722c6a | ||
|
|
91e72f60f8 | ||
|
|
5bff1c80a7 | ||
|
|
ed5e7ee6eb | ||
|
|
1c4cac2397 | ||
|
|
c4b9b3df95 | ||
|
|
e61d0409ac | ||
|
|
e0ef9c82e9 |
@@ -1,50 +1,58 @@
|
|||||||
#! /bin/sh
|
#! /usr/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
. /usr/share/grub/grub-mkconfig_lib
|
. /usr/share/grub/grub-mkconfig_lib
|
||||||
. /etc/default/grub
|
. /etc/default/grub
|
||||||
|
|
||||||
### variables modifiable ###
|
######################################
|
||||||
## fr: nom du sous-menu
|
### variables in /etc/default/grub ###
|
||||||
## en: Name of the submenu
|
######################################
|
||||||
|
## Submenu name
|
||||||
submenuname=${GRUB_BTRFS_SUBMENUNAME:-"ArchLinux Snapshots"}
|
submenuname=${GRUB_BTRFS_SUBMENUNAME:-"ArchLinux Snapshots"}
|
||||||
## fr: préfixe de l'entrée
|
## Prefix entry
|
||||||
## en: Prefix entry
|
|
||||||
prefixentry=${GRUB_BTRFS_PREFIXENTRY:-"Snapshot"}
|
prefixentry=${GRUB_BTRFS_PREFIXENTRY:-"Snapshot"}
|
||||||
## fr: nom(s) du ou des kernel(s)
|
## Kernel(s) name(s)
|
||||||
## en: Name(s) of the kernel(s)
|
|
||||||
nkernel=("${GRUB_BTRFS_NKERNEL[@]:-vmlinuz-linux}")
|
nkernel=("${GRUB_BTRFS_NKERNEL[@]:-vmlinuz-linux}")
|
||||||
## fr: nom(s) de(s) l'init
|
## Initramfs name(s)
|
||||||
## en: Name(s) of the init(s)
|
|
||||||
ninit=("${GRUB_BTRFS_NINIT[@]:-initramfs-linux.img initramfs-linux-fallback.img}")
|
ninit=("${GRUB_BTRFS_NINIT[@]:-initramfs-linux.img initramfs-linux-fallback.img}")
|
||||||
## fr: nom du microcode intel
|
## Intel-ucode name(s)
|
||||||
## en: Name intel-ucode
|
|
||||||
intel_ucode=("${GRUB_BTRFS_INTEL_UCODE[@]:-intel-ucode.img}")
|
intel_ucode=("${GRUB_BTRFS_INTEL_UCODE[@]:-intel-ucode.img}")
|
||||||
|
|
||||||
|
########################
|
||||||
###########################
|
### variables script ###
|
||||||
### fr: DÉBUT DU SCRIPT ###
|
########################
|
||||||
### en: NAME OF SCRIPT ###
|
## Internationalization (default : english)
|
||||||
### fr: NE PAS TOUCHER ###
|
|
||||||
### en: DO NOT TOUCH ###
|
|
||||||
###########################
|
|
||||||
## fr: internationalisation
|
|
||||||
## en: Internationalization
|
|
||||||
export TEXTDOMAIN=grub-btrfs-git
|
export TEXTDOMAIN=grub-btrfs-git
|
||||||
export TEXTDOMAINDIR="/usr/share/locale"
|
export TEXTDOMAINDIR="/usr/share/locale"
|
||||||
## fr: paramêtre des chaînes --hint
|
## fr: paramêtre des chaînes --hint
|
||||||
## en: Parameter of the chains --hint (Translation unclear)
|
## en: Parameter of the chains --hint (Translation unclear)
|
||||||
pboot=$(${grub_probe} --target="hints_string" "/boot" 2>/dev/null)
|
pboot=$(${grub_probe} --target="hints_string" "/boot" 2>/dev/null)
|
||||||
## fr: uuid de la partition root
|
## UUID of the root partition
|
||||||
## en: UUID of the root partition
|
|
||||||
uuid=$(${grub_probe} "/" --target="fs_uuid" 2>/dev/null)
|
uuid=$(${grub_probe} "/" --target="fs_uuid" 2>/dev/null)
|
||||||
## fr: uuid de la partition boot
|
## UUID of the boot partition
|
||||||
## en: UUID of the boot partition
|
|
||||||
buuid=$(${grub_probe} --target="fs_uuid" "/boot" 2>/dev/null)
|
buuid=$(${grub_probe} --target="fs_uuid" "/boot" 2>/dev/null)
|
||||||
## fr: paramêtre passé au kernel
|
## Parameters passed to the kernel
|
||||||
## en: Parameters passed to the kernel
|
|
||||||
params="$GRUB_CMDLINE_LINUX $GRUB_CMDLINE_LINUX_DEFAULT"
|
params="$GRUB_CMDLINE_LINUX $GRUB_CMDLINE_LINUX_DEFAULT"
|
||||||
|
|
||||||
|
##############
|
||||||
|
### Script ###
|
||||||
|
##############
|
||||||
|
|
||||||
|
typeset -A date_time
|
||||||
|
unset snapshots
|
||||||
|
|
||||||
|
# Create list of filesystem snapshots
|
||||||
|
oldIFS=$IFS
|
||||||
|
IFS=$'\n'
|
||||||
|
|
||||||
|
for snap in $($bindir/btrfs subvolume list -sa / --sort=-ogen | $bindir/awk '{gsub(/^["<FS_TREE>/"]+/,"",$NF);print $11" "$12"?"$NF}'); do
|
||||||
|
snap_name="${snap#*"?"}"
|
||||||
|
# Discard deleted snapshots
|
||||||
|
if [ $snap_name = "DELETED" ]; then continue; fi
|
||||||
|
snapshots+=("$snap_name")
|
||||||
|
date_time[$snap_name]="${snap%"?"*}"
|
||||||
|
done
|
||||||
|
IFS=$oldIFS
|
||||||
|
|
||||||
# fr: on affiche le menu
|
# fr: on affiche le menu
|
||||||
# en: Display the menu
|
# en: Display the menu
|
||||||
@@ -60,20 +68,15 @@ for kernel in ${nkernel[@]}; do
|
|||||||
# en: If there are >1 kernels, create a menu
|
# en: If there are >1 kernels, create a menu
|
||||||
if [ ${#nkernel[*]} != 1 ]; then echo " submenu '$kernel' {
|
if [ ${#nkernel[*]} != 1 ]; then echo " submenu '$kernel' {
|
||||||
submenu '---> Kernel: $kernel <---' { echo }"; fi
|
submenu '---> Kernel: $kernel <---' { echo }"; fi
|
||||||
|
# fr: On traite la variable snapshots
|
||||||
# fr: On liste les snapshots présent sur le système de fichier
|
# en: Treat the snapshots variable
|
||||||
# en: List filesystem snapshots
|
for item in ${snapshots[@]}; do
|
||||||
for item in $($bindir/btrfs subvolume list -s / --sort=-ogen | $bindir/awk '{print $NF}'); do
|
|
||||||
# fr: On écarte les snapshots avec un statut de suppression
|
|
||||||
# en: Discard deleted snapshots
|
|
||||||
if [ $item = "DELETED" ]; then continue; fi
|
|
||||||
# fr: affiche la liste des snapshots trouvés
|
# fr: affiche la liste des snapshots trouvés
|
||||||
# en: Output name of snapshot
|
# en: Output name of snapshot
|
||||||
gettext_printf $"Found Snapshot: %s\n" "$item" >&2
|
gettext_printf $"Found Snapshot: %s\n" "$item ${date_time[$item]}" >&2
|
||||||
# fr: on crée un menu pour chaque snapshot présent (nom + date de création)
|
# fr: on crée un menu pour chaque snapshot présent (nom + date de création)
|
||||||
# en: Create a menu for remaining snapshots (name + creation date)
|
# en: Create a menu for remaining snapshots (name + creation date)
|
||||||
date_time=$($bindir/btrfs subvolume list -s / | $bindir/grep $item | $bindir/cut -d" " -f 11-12)
|
echo " submenu '$prefixentry $item [${date_time[$item]}]' {"
|
||||||
echo " submenu '$prefixentry $item [$date_time]' {"
|
|
||||||
# fr: si plusieurs kernel on été trouvé, on affiche un titre indicatif
|
# fr: si plusieurs kernel on été trouvé, on affiche un titre indicatif
|
||||||
# en: if more than one kernel is found, create a menu
|
# en: if more than one kernel is found, create a menu
|
||||||
if [ ${#nkernel[*]} != 1 ]; then echo " submenu '---> Kernel: $kernel <---' { echo }"; fi
|
if [ ${#nkernel[*]} != 1 ]; then echo " submenu '---> Kernel: $kernel <---' { echo }"; fi
|
||||||
@@ -133,4 +136,4 @@ for kernel in ${nkernel[@]}; do
|
|||||||
# en: Don't forget to close menus if more than one kernel is found
|
# en: Don't forget to close menus if more than one kernel is found
|
||||||
if [ ${#nkernel[*]} != 1 ]; then echo " }"; fi
|
if [ ${#nkernel[*]} != 1 ]; then echo " }"; fi
|
||||||
done
|
done
|
||||||
echo "}"
|
echo "}"
|
||||||
Reference in New Issue
Block a user