From 0182e119516a14d49778bec94d3aeb9ce5742a83 Mon Sep 17 00:00:00 2001 From: David P Date: Sun, 26 Jun 2022 19:30:30 -0400 Subject: [PATCH] OpenRC scripts: add configuration file This allows users to customize the snapshots path to work with, e.g., snapper. If no path is configured, it will default to timeshift. Signed-off-by: David P --- Makefile | 5 +++-- grub-btrfs-openrc | 3 ++- grub-btrfsd.confd | 3 +++ grub-btrfsd => grub-btrfsd.initd | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 grub-btrfsd.confd rename grub-btrfsd => grub-btrfsd.initd (90%) diff --git a/Makefile b/Makefile index f0ae86a..04b1575 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,8 @@ install: @# OpenRC init system @if test "$(OPENRC)" = true; then \ install -Dm744 -t "$(BIN_DIR)/" grub-btrfs-openrc; \ - install -Dm744 -t "$(DESTDIR)/etc/init.d/" grub-btrfsd; \ + install -Dm744 grub-btrfsd.initd "$(DESTDIR)/etc/init.d/grub-btrfsd"; \ + install -Dm644 grub-btrfsd.confd "$(DESTDIR)/etc/conf.d/grub-btrfsd"; \ fi @# Arch Linux like distros only : @if test "$(INITCPIO)" = true; then \ @@ -83,4 +84,4 @@ help: @echo " INITCPIO | bool | include mkinitcpio hook | false" @echo " SYSTEMD | bool | include unit files | true" @echo " OPENRC | bool | include OpenRc daemon | false" - @echo \ No newline at end of file + @echo diff --git a/grub-btrfs-openrc b/grub-btrfs-openrc index 57e1a55..988be81 100755 --- a/grub-btrfs-openrc +++ b/grub-btrfs-openrc @@ -1,6 +1,7 @@ #!/bin/sh echo $$ > /run/grub-btrfsd.pid +snapshots="${1:-/run/timeshift/backup/timeshift-btrfs/snapshots}" -while true; do sleep 1 && inotifywait -e create -e delete /run/timeshift/backup/timeshift-btrfs/snapshots && sleep 5 && if [ -s "${GRUB_BTRFS_GRUB_DIRNAME:-/boot/grub}/grub-btrfs.cfg" ]; then /etc/grub.d/41_snapshots-btrfs; else ${GRUB_BTRFS_MKCONFIG:-grub-mkconfig} -o ${GRUB_BTRFS_GRUB_DIRNAME:-/boot/grub}/grub.cfg; fi ; done +while true; do sleep 1 && inotifywait -e create -e delete "$snapshots" && sleep 5 && if [ -s "${GRUB_BTRFS_GRUB_DIRNAME:-/boot/grub}/grub-btrfs.cfg" ]; then /etc/grub.d/41_snapshots-btrfs; else ${GRUB_BTRFS_MKCONFIG:-grub-mkconfig} -o ${GRUB_BTRFS_GRUB_DIRNAME:-/boot/grub}/grub.cfg; fi ; done diff --git a/grub-btrfsd.confd b/grub-btrfsd.confd new file mode 100644 index 0000000..9033c82 --- /dev/null +++ b/grub-btrfsd.confd @@ -0,0 +1,3 @@ +# Where to locate the root snapshots +#snapshots="/.snapshots" # Snapper in the root directory +snapshots="/run/timeshift/backup/timeshift-btrfs/snapshots" # Timeshift diff --git a/grub-btrfsd b/grub-btrfsd.initd similarity index 90% rename from grub-btrfsd rename to grub-btrfsd.initd index 971aa62..3782782 100755 --- a/grub-btrfsd +++ b/grub-btrfsd.initd @@ -4,6 +4,7 @@ name="grub-btrfs daemon" command="/usr/bin/grub-btrfs-openrc" +command_args="${snapshots}" pidfile="/run/{RC_SVCNAME}.pid" command_background=true