Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/Development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Antynea committed Jun 2, 2015
2 parents 5bff1c8 + 5e8c722 commit 5fe28d3
Showing 1 changed file with 41 additions and 38 deletions.
79 changes: 41 additions & 38 deletions 41_snapshots-btrfs
Original file line number Diff line number Diff line change
@@ -1,50 +1,58 @@
#! /bin/sh
#! /usr/bin/bash
set -e

. /usr/share/grub/grub-mkconfig_lib
. /etc/default/grub

### variables modifiable ###
## fr: nom du sous-menu
## en: Name of the submenu
######################################
### variables in /etc/default/grub ###
######################################
## Submenu name
submenuname=${GRUB_BTRFS_SUBMENUNAME:-"ArchLinux Snapshots"}
## fr: préfixe de l'entrée
## en: Prefix entry
## Prefix entry
prefixentry=${GRUB_BTRFS_PREFIXENTRY:-"Snapshot"}
## fr: nom(s) du ou des kernel(s)
## en: Name(s) of the kernel(s)
## Kernel(s) name(s)
nkernel=("${GRUB_BTRFS_NKERNEL[@]:-vmlinuz-linux}")
## fr: nom(s) de(s) l'init
## en: Name(s) of the init(s)
## Initramfs name(s)
ninit=("${GRUB_BTRFS_NINIT[@]:-initramfs-linux.img initramfs-linux-fallback.img}")
## fr: nom du microcode intel
## en: Name intel-ucode
## Intel-ucode name(s)
intel_ucode=("${GRUB_BTRFS_INTEL_UCODE[@]:-intel-ucode.img}")


###########################
### fr: DÉBUT DU SCRIPT ###
### en: NAME OF SCRIPT ###
### fr: NE PAS TOUCHER ###
### en: DO NOT TOUCH ###
###########################
## fr: internationalisation
## en: Internationalization
########################
### variables script ###
########################
## Internationalization (default : english)
export TEXTDOMAIN=grub-btrfs-git
export TEXTDOMAINDIR="/usr/share/locale"
## fr: paramêtre des chaînes --hint
## en: Parameter of the chains --hint (Translation unclear)
pboot=$(${grub_probe} --target="hints_string" "/boot" 2>/dev/null)
## fr: uuid de la partition root
## en: UUID of the root partition
## UUID of the root partition
uuid=$(${grub_probe} "/" --target="fs_uuid" 2>/dev/null)
## fr: uuid de la partition boot
## en: UUID of the boot partition
## UUID of the boot partition
buuid=$(${grub_probe} --target="fs_uuid" "/boot" 2>/dev/null)
## fr: paramêtre passé au kernel
## en: Parameters passed to the kernel
## Parameters passed to the kernel
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
# en: Display the menu
Expand All @@ -60,20 +68,15 @@ for kernel in ${nkernel[@]}; do
# en: If there are >1 kernels, create a menu
if [ ${#nkernel[*]} != 1 ]; then echo " submenu '$kernel' {
submenu '---> Kernel: $kernel <---' { echo }"; fi

# fr: On liste les snapshots présent sur le système de fichier
# en: List filesystem snapshots
for item in $($bindir/btrfs subvolume list -sa / --sort=-ogen | $bindir/awk '{gsub(/^["<FS_TREE>/"]+/,"",$NF);print $NF}'); do
# fr: On écarte les snapshots avec un status de suppression
# en: Discard deleted snapshots
if [ $item = "DELETED" ]; then continue; fi
# fr: On traite la variable snapshots
# en: Treat the snapshots variable
for item in ${snapshots[@]}; do
# fr: affiche la liste des snapshots trouvés
# en: Output name of snapshot
date_time=$($bindir/btrfs subvolume list -sa / | $bindir/grep $item | $bindir/cut -d" " -f 11-12)
gettext_printf $"Found Snapshot: %s\n" "$item $date_time" >&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)
# en: Create a menu for remaining snapshots (name + creation date)
echo " submenu '$prefixentry $item [$date_time]' {"
echo " submenu '$prefixentry $item [${date_time[$item]}]' {"
# fr: si plusieurs kernel on été trouvé, on affiche un titre indicatif
# en: if more than one kernel is found, create a menu
if [ ${#nkernel[*]} != 1 ]; then echo " submenu '---> Kernel: $kernel <---' { echo }"; fi
Expand Down Expand Up @@ -133,4 +136,4 @@ for kernel in ${nkernel[@]}; do
# en: Don't forget to close menus if more than one kernel is found
if [ ${#nkernel[*]} != 1 ]; then echo " }"; fi
done
echo "}"
echo "}"

0 comments on commit 5fe28d3

Please sign in to comment.