Skip to content

Commit

Permalink
Merge pull request #210 from Megver83/openrc
Browse files Browse the repository at this point in the history
OpenRC scripts: add configuration file
  • Loading branch information
Schievel1 authored Sep 2, 2022
2 parents 3dc1d89 + 0182e11 commit c78bd25
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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
@echo
3 changes: 2 additions & 1 deletion grub-btrfs-openrc
Original file line number Diff line number Diff line change
@@ -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


3 changes: 3 additions & 0 deletions grub-btrfsd.confd
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions grub-btrfsd → grub-btrfsd.initd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c78bd25

Please sign in to comment.