Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for snapper could hook in plugins #314

Open
bastien-roucaries opened this issue Jan 27, 2024 · 5 comments
Open

for snapper could hook in plugins #314

bastien-roucaries opened this issue Jan 27, 2024 · 5 comments

Comments

@bastien-roucaries
Copy link
Contributor

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
Copy link
Contributor Author

@Schievel1 can you get a glimse ?

@Schievel1
Copy link
Collaborator

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
Copy link
Contributor Author

@Schievel1
Copy link
Collaborator

Schievel1 commented Feb 19, 2024

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
Copy link
Contributor Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants