Antynea / grub-btrfs

Include btrfs snapshots at boot options. (Grub menu)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

for snapper could hook in plugins

bastien-roucaries opened this issue · comments

Hi,

I really believe for snapper a good configuration is plugins one
create-snapshot-post subvolume fstype snapshot-number
delete-snapshot-post subvolume fstype snapshot-number

Could you please give me some guidance of how achieve this kind of modification ?

Thanks

Bastien

@Schievel1 can you get a glimse ?

Sorry, but I do not understand what you mean by this. It probably is because I am using timeshift personally and just use snapper occasionally when testing out things.

ok, I read that but I am still a bit confused what you want to do.
Do you want to create a new grub submenu whenever snapper makes a new snapshot? This is actually what grub-btrfsd is for, but you could do a script like this in /usr/lib/snapper/plugins

#!/usr/bin/env bash

create_grub_menu() {
    #  create the grub submenu of the whole grub menu, depending on whether the submenu already exists
    #  and gives feedback if it worked
    if grep "snapshots-btrfs" "${GRUB_BTRFS_GRUB_DIRNAME:-/boot/grub}"/grub.cfg; then
    	  if  /etc/grub.d/41_snapshots-btrfs; then
		        echo "Grub submenu recreated"
          else
		      echo "[!] Error during grub submenu creation (grub-btrfs error)"
          fi
    else
        if ${GRUB_BTRFS_MKCONFIG:-grub-mkconfig} -o "${GRUB_BTRFS_GRUB_DIRNAME:-/boot/grub}"/grub.cfg; then
		    echo "Grub menu recreated"
	    else
		    echo "[!] Error during grub menu creation (grub/ grub-btrfs error)"
	    fi
    fi
}

if [[ $1 == "create-snapshot-post" || $1 == "delete-snapshot-post" ]]; then
    create_grub_menu
fi

Something like that?

@Schievel1 yes something like this snapper could be send in modern language push notification every time it create an interesting notification.

You use here a full hammer that is every time you get a notification, you recreate the whole menu, but if you could run grub-btrfs special hook it could be more efficient