Compare commits

..

29 Commits
v0.1 ... v0.5.1

Author SHA1 Message Date
Antynea
5bff1c80a7 Merge remote-tracking branch 'origin/Development' 2015-05-24 15:57:50 +02:00
Antynea
ed5e7ee6eb Improve snapshot detection 2015-05-23 16:06:05 +02:00
Antynea
1c4cac2397 Merge remote-tracking branch 'origin/Development' 2015-05-19 00:43:36 +02:00
Antynea
c4b9b3df95 Update README.md
Oops rollback last commit
2015-05-15 22:13:15 +02:00
Antynea
9fb9146e5b Update README.md
reflects change
2015-05-15 22:12:26 +02:00
Antynea
e61d0409ac Merge pull request #6 from penetal/patch-3
How to use /etc/default/grub config
2015-05-15 11:45:22 +02:00
Antynea
3f56de34ec Merge pull request #5 from penetal/patch-2
Pull config from /etc/default/grub
2015-05-15 11:44:14 +02:00
penetal
e0ef9c82e9 How to use /etc/default/grub config
How to change from default config via /etc/default/grub
2015-05-15 11:23:46 +02:00
penetal
788390cc93 Pull config from /etc/default/grub
Added parameter substitution so variables can be changed in /etc/default/grub.
This will let the script stay untouched, for easier updating.
2015-05-15 11:17:46 +02:00
Antynea
97dcaeae58 add warning 2015-05-14 00:38:10 +02:00
Antynea
8602220b98 Add warning 2015-05-13 23:59:07 +02:00
Antynea
7441e573f3 Ooops 2015-05-13 10:30:58 +02:00
Antynea
e06a8e1dd8 enhanced 2015-05-13 10:27:56 +02:00
Antynea
aeff81e861 enhanced 2015-05-13 10:22:36 +02:00
Antynea
876d1c5e98 enhanced 2015-05-13 10:20:00 +02:00
Antynea
4fb1f71b17 enhanced 2015-05-13 10:18:32 +02:00
Antynea
b80c04a751 enhanced 2015-05-13 10:15:13 +02:00
Antynea
11af1f69ba enhanced 2015-05-13 10:13:11 +02:00
Antynea
5ca00a1aa2 enhanced 2015-05-13 10:11:53 +02:00
Antynea
a1b876188c test 2015-05-13 10:10:59 +02:00
Antynea
50f63a9bec enhanced 2015-05-13 10:09:36 +02:00
Antynea
a10f775b8d enhanced 2015-05-13 10:06:57 +02:00
Antynea
7ebfbe05f9 enhanced 2015-05-13 10:03:24 +02:00
Antynea
eeae1d3084 Add intel microcode 2015-05-13 06:23:27 +02:00
Antynea
6a76ec8837 Internationalisation
by default, message en
add translate message fr
2015-05-12 07:40:18 +02:00
Antynea
7916ca2da9 Update 41_snapshots-btrfs
Ooops
2015-05-12 00:52:18 +02:00
Antynea
6b4e3f05e7 upgrade 41_snapshots-btrfs
Add date to menu entry + Output name of accepted snapshots
2015-05-11 22:45:46 +02:00
Antynea
618f82af2f Merge pull request #1 from crossroads1112/patch-1
Add English translation of comments
2015-05-08 17:20:34 +02:00
Chad Sharp
1120c268f2 Add English translation of comments 2015-05-08 09:58:56 -04:00
3 changed files with 124 additions and 37 deletions

View File

@@ -5,54 +5,86 @@ set -e
. /etc/default/grub
### variables modifiable ###
## nom du sous-menu
submenuname="ArchLinux Snapshots"
## préfixe de l'entrée
prefixentry="Snapshot"
## nom(s) du ou des kernel(s)
nkernel=("vmlinuz-linux")
## nom(s) de(s) l'init
ninit=("initramfs-linux.img" "initramfs-linux-fallback.img")
## fr: nom du sous-menu
## en: Name of the submenu
submenuname=${GRUB_BTRFS_SUBMENUNAME:-"ArchLinux Snapshots"}
## fr: préfixe de l'entrée
## en: Prefix entry
prefixentry=${GRUB_BTRFS_PREFIXENTRY:-"Snapshot"}
## fr: nom(s) du ou des kernel(s)
## en: Name(s) of the kernel(s)
nkernel=("${GRUB_BTRFS_NKERNEL[@]:-vmlinuz-linux}")
## fr: nom(s) de(s) l'init
## en: Name(s) of the init(s)
ninit=("${GRUB_BTRFS_NINIT[@]:-initramfs-linux.img initramfs-linux-fallback.img}")
## fr: nom du microcode intel
## en: Name intel-ucode
intel_ucode=("${GRUB_BTRFS_INTEL_UCODE[@]:-intel-ucode.img}")
#######################
### DÉBUT DU SCRIPT ###
### NE PAS TOUCHER ###
#######################
## paramêtre des chaînes --hint
###########################
### fr: DÉBUT DU SCRIPT ###
### en: NAME OF SCRIPT ###
### fr: NE PAS TOUCHER ###
### en: DO NOT TOUCH ###
###########################
## fr: internationalisation
## en: Internationalization
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)
## uuid de la partition root
## fr: uuid de la partition root
## en: UUID of the root partition
uuid=$(${grub_probe} "/" --target="fs_uuid" 2>/dev/null)
## uuid de la partition boot
## fr: uuid de la partition boot
## en: UUID of the boot partition
buuid=$(${grub_probe} --target="fs_uuid" "/boot" 2>/dev/null)
## paramêtre passé au kernel
## fr: paramêtre passé au kernel
## en: Parameters passed to the kernel
params="$GRUB_CMDLINE_LINUX $GRUB_CMDLINE_LINUX_DEFAULT"
# on affiche le menu
# fr: on affiche le menu
# en: Display the menu
echo "submenu '$submenuname' {"
# on traite la variable kernel
# fr: on traite la variable kernel
# en: Treat the kernel variables (Translation unclear)
for kernel in ${nkernel[@]}; do
# on test si le(s) nom(s) du(des) kernel existe(nt), autrement on affiche une erreur et on sort
if [ ! -f /boot/$kernel ]; then echo "/boot/$kernel: Fichier inexistant" >&2; exit 1; fi
# on vérifie le nombre de kernel présent, si >1 on crée un menu
# fr: on test si le(s) nom(s) du(des) kernel existe(nt), autrement on affiche une erreur et on sort
# en: Check the specified kernel(s) exist, if it/they don't, display an error and exit
if [ ! -f /boot/$kernel ]; then gettext_printf $"Error: /boot/$kernel, kernel does not exist" >&2; exit 1; fi
# fr: on vérifie le nombre de kernel présent, si >1 on crée un menu
# en: If there are >1 kernels, create a menu
if [ ${#nkernel[*]} != 1 ]; then echo " submenu '$kernel' {
submenu '---> Kernel: $kernel <---' { echo }"; fi
# On liste les snapshots présent sur le système de fichier
for item in $($bindir/btrfs subvolume list -s / --sort=-ogen | $bindir/awk '{print $NF}'); do
# On écarte les snapshots avec un statut de suppression
# 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
# on crée un menu pour chaque snapshot présent
echo " submenu '$prefixentry $item' {"
# si plusieurs kernel on été trouvé, on affiche un titre indicatif
# 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
# 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]' {"
# 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
# on traite la variable de l'initframs
# fr: on traite la variable de l'initramfs
# en: Treat the initramfs variables (Translation unclear)
for init in ${ninit[@]}; do
# on test si le(s) nom(s) du(des) initframs existe(nt), autrement on affiche une erreur et on sort
if [ ! -f /boot/$init ]; then echo "/boot/$init: Fichier inexistant" >&2; exit 1; fi
# on traite chaque entrée des snapshots avec leurs kernel et initframs respectifs
# fr: on test si le(s) nom(s) du(des) initramfs existe(nt), autrement on affiche une erreur et on sort
# en: Check the specified initramfs(es) exist, if it/they don't, display an error and exit
if [ ! -f /boot/$init ]; then gettext_printf $"Error: /boot/$init, initramfs does not exist" >&2; exit 1; fi
# fr: on traite chaque entrée des snapshots avec leurs kernel et initramfs respectifs
# en: Specify a kernel and initramfs for every snapshot
echo "\
menuentry '$item $init' --class arch --class gnu-linux --class gnu --class os "\$menuentry_id_option" 'gnulinux-snapshots-$uuid'{
load_video
@@ -63,24 +95,42 @@ for kernel in ${nkernel[@]}; do
search --no-floppy --fs-uuid --set=root $buuid
fi
echo 'Loading Linux snapshot ...'"
# on vérifie l'emplacement de la partition /boot
# fr: on vérifie l'emplacement de la partition /boot
# en: Check the location of the /boot partition
if [ $uuid = $buuid ]; then
echo "\
linux /$item/boot/$kernel root=UUID=$uuid rw rootflags=subvol=$item $params
echo 'Loading initial ramdisk ...'
echo 'Loading initial ramdisk ...'"
# fr: on vérifie la présence du microcode intel
# en: Check intel microcode exist
if [ -f /boot/$intel_ucode ]; then
echo "\
initrd /$item/boot/$intel_ucode /$item/boot/$init"
else
echo "\
initrd /$item/boot/$init"
fi
else
echo "\
linux /$kernel root=UUID=$uuid rw rootflags=subvol=$item $params
echo 'Loading initial ramdisk ...'
echo 'Loading initial ramdisk ...'"
# fr: on vérifie la présence du microcode intel
# en: Check intel microcode exist
if [ -f /boot/$intel_ucode ]; then
echo "\
initrd /$intel_ucode /$init"
else
echo "\
initrd /$init"
fi
fi
echo "\
}"
done
echo " }"
done
# on oubli pas de fermer le menu si plusieurs kernels ont été trouvé
# fr: on oubli pas de fermer le menu si plusieurs kernels ont été trouvé
# en: Don't forget to close menus if more than one kernel is found
if [ ${#nkernel[*]} != 1 ]; then echo " }"; fi
done
echo "}"

View File

@@ -1,4 +1,41 @@
grub-btrfs
==========
### grub-btrfs
This is a version 0.xx of grub-btrfs
#### Description
grub-btrfs, add support for btrfs snapshots into grub menu
#### What does grub-btrfs v0.xx do :
Simple rollback using snapshots you made previous.
Makes a list of all snapshots, kernels, initramfs present on the filesystem and then creates a corresponding entered with name and date of snapshots in grub.cfg, which ensures a very easy rollback.
#### How to use it :
1. Add lines to /etc/default/grub as needed, defaults listed as examples:
2.
* submenuname = name menu appear in grub ( e.g: GRUB_BTRFS_SUBMENUNAME="ArchLinux Snapshots" )
* prefixentry = add a name ahead your snapshots entries ( e.g: GRUB_BTRFS_PREFIXENTRY="Snapshot" )
* nkernel= name kernel you use it ( e.g: GRUB_BTRFS_NKERNEL=("vmlinuz-linux") )
* ninit= name initramfs (ramdisk) you use it ( e.g: GRUB_BTRFS_NINIT=("initramfs-linux.img" "initramfs-linux-fallback.img") )
* intel_ucode= name intel microcode you use it ( e.g: GRUB_BTRFS_INTEL_UCODE=("intel-ucode.img") )
2. Generate grub.cfg (on Archlinux is grub-mkconfig -o /boot/grub/grub.cfg )
grub-btrfs automatically generates snapshots entries.
You will see it appear different entries, e.g : Prefixentry name of snapshot [2013-02-11 04:00:00]
#### Warning
Version 0.xx detect kernels,initramfs,intel microcode only in boot partition, not in snapshot.
If kernels,initramfs,intel microcode, are present in boot partition but not in snapshot, entry will be created but not fonctional, you don't boot it.
Version 1.xx will do it, release soon.

Binary file not shown.