Antynea / grub-btrfs

Include btrfs snapshots at boot options. (Grub menu)
GNU General Public License v3.0
745 stars 77 forks source link

for snapper could hook in plugins #314

Open bastien-roucaries opened 8 months ago

bastien-roucaries commented 8 months ago

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

bastien-roucaries commented 7 months ago

@Schievel1 can you get a glimse ?

Schievel1 commented 7 months ago

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.

bastien-roucaries commented 7 months ago

See https://man.archlinux.org/man/snapper.8.en#PLUGINS

Schievel1 commented 7 months ago

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?

bastien-roucaries commented 6 months ago

@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