Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- src/initscripts/system/functions | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions index 5a26aef45..b610143ab 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -883,3 +883,11 @@ running_on_oci() { # We are not running on OCI return 1 } + +volume_fs_type() { + if [ ! -d "${1}" ]; then + return + fi + + stat -f --format="%T" ${1} +}
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- src/initscripts/system/grub-btrfsd | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/src/initscripts/system/grub-btrfsd b/src/initscripts/system/grub-btrfsd index dc5e32ad4..90582b1b1 100644 --- a/src/initscripts/system/grub-btrfsd +++ b/src/initscripts/system/grub-btrfsd @@ -25,21 +25,18 @@ SNAPSHOTDIR="/.snapshots" PIDFILE="/run/grub-btrfsd.pid"
-root_is_btrfs() { - [ "$(stat -f --format="%T" /)" == "btrfs" ] || return 1 - - return 0 -} - case "$1" in start) - root_is_btrfs || exit 0 + root_fs_type=$(volume_fs_type "/")
- boot_mesg "Starting Grub/Btrfs snapshot manager..." - loadproc -b -p "$PIDFILE" /usr/bin/grub-btrfsd --syslog "$SNAPSHOTDIR" + case "$root_fs_type" in + btrfs)
- # Store the gained PID to the defined pidfile - echo "$!" > "$PIDFILE" + boot_mesg "Starting Grub/Btrfs snapshot manager..." + loadproc -b -p "$PIDFILE" /usr/bin/grub-btrfsd --syslog "$SNAPSHOTDIR" + echo "$!" > "$PIDFILE" + ;; + esac ;;
stop)
Reviewed-by: Michael Tremer michael.tremer@ipfire.org
On 27 Mar 2024, at 19:39, Stefan Schantl stefan.schantl@ipfire.org wrote:
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
src/initscripts/system/grub-btrfsd | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/src/initscripts/system/grub-btrfsd b/src/initscripts/system/grub-btrfsd index dc5e32ad4..90582b1b1 100644 --- a/src/initscripts/system/grub-btrfsd +++ b/src/initscripts/system/grub-btrfsd @@ -25,21 +25,18 @@ SNAPSHOTDIR="/.snapshots" PIDFILE="/run/grub-btrfsd.pid"
-root_is_btrfs() {
- [ "$(stat -f --format="%T" /)" == "btrfs" ] || return 1
- return 0
-}
case "$1" in start)
- root_is_btrfs || exit 0
- root_fs_type=$(volume_fs_type "/")
- boot_mesg "Starting Grub/Btrfs snapshot manager..."
- loadproc -b -p "$PIDFILE" /usr/bin/grub-btrfsd --syslog "$SNAPSHOTDIR"
- case "$root_fs_type" in
- btrfs)
- # Store the gained PID to the defined pidfile
- echo "$!" > "$PIDFILE"
- boot_mesg "Starting Grub/Btrfs snapshot manager..."
- loadproc -b -p "$PIDFILE" /usr/bin/grub-btrfsd --syslog "$SNAPSHOTDIR"
- echo "$!" > "$PIDFILE"
- ;;
- esac
;;
stop)
2.39.2
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- src/initscripts/system/grub-btrfsd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/initscripts/system/grub-btrfsd b/src/initscripts/system/grub-btrfsd index 90582b1b1..26760f9be 100644 --- a/src/initscripts/system/grub-btrfsd +++ b/src/initscripts/system/grub-btrfsd @@ -32,7 +32,7 @@ case "$1" in case "$root_fs_type" in btrfs)
- boot_mesg "Starting Grub/Btrfs snapshot manager..." + boot_mesg "Starting GRUB/Btrfs Daemon..." loadproc -b -p "$PIDFILE" /usr/bin/grub-btrfsd --syslog "$SNAPSHOTDIR" echo "$!" > "$PIDFILE" ;;
Reviewed-by: Michael Tremer michael.tremer@ipfire.org
On 27 Mar 2024, at 19:39, Stefan Schantl stefan.schantl@ipfire.org wrote:
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
src/initscripts/system/grub-btrfsd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/initscripts/system/grub-btrfsd b/src/initscripts/system/grub-btrfsd index 90582b1b1..26760f9be 100644 --- a/src/initscripts/system/grub-btrfsd +++ b/src/initscripts/system/grub-btrfsd @@ -32,7 +32,7 @@ case "$1" in case "$root_fs_type" in btrfs)
- boot_mesg "Starting Grub/Btrfs snapshot manager..."
- boot_mesg "Starting GRUB/Btrfs Daemon..."
loadproc -b -p "$PIDFILE" /usr/bin/grub-btrfsd --syslog "$SNAPSHOTDIR" echo "$!" > "$PIDFILE" ;; -- 2.39.2
This case is already covered by the PID mechanism of the used functions
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org --- src/initscripts/system/grub-btrfsd | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/initscripts/system/grub-btrfsd b/src/initscripts/system/grub-btrfsd index 26760f9be..49073a807 100644 --- a/src/initscripts/system/grub-btrfsd +++ b/src/initscripts/system/grub-btrfsd @@ -33,16 +33,14 @@ case "$1" in btrfs)
boot_mesg "Starting GRUB/Btrfs Daemon..." - loadproc -b -p "$PIDFILE" /usr/bin/grub-btrfsd --syslog "$SNAPSHOTDIR" - echo "$!" > "$PIDFILE" + loadproc -b /usr/bin/grub-btrfsd --syslog "$SNAPSHOTDIR" ;; esac ;;
stop) boot_mesg "Stopping grub-btrfsd..." - killproc -p "$PIDFILE" /usr/bin/grub-btrfsd - sleep 1; + killproc /usr/bin/grub-btrfsd ;;
restart)
Reviewed-by: Michael Tremer michael.tremer@ipfire.org
On 27 Mar 2024, at 19:39, Stefan Schantl stefan.schantl@ipfire.org wrote:
This case is already covered by the PID mechanism of the used functions
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
src/initscripts/system/grub-btrfsd | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/initscripts/system/grub-btrfsd b/src/initscripts/system/grub-btrfsd index 26760f9be..49073a807 100644 --- a/src/initscripts/system/grub-btrfsd +++ b/src/initscripts/system/grub-btrfsd @@ -33,16 +33,14 @@ case "$1" in btrfs)
boot_mesg "Starting GRUB/Btrfs Daemon..."
- loadproc -b -p "$PIDFILE" /usr/bin/grub-btrfsd --syslog "$SNAPSHOTDIR"
- echo "$!" > "$PIDFILE"
- loadproc -b /usr/bin/grub-btrfsd --syslog "$SNAPSHOTDIR"
;; esac ;;
stop) boot_mesg "Stopping grub-btrfsd..."
- killproc -p "$PIDFILE" /usr/bin/grub-btrfsd
- sleep 1;
- killproc /usr/bin/grub-btrfsd
;;
restart)
2.39.2
Reviewed-by: Michael Tremer michael.tremer@ipfire.org
On 27 Mar 2024, at 19:39, Stefan Schantl stefan.schantl@ipfire.org wrote:
Signed-off-by: Stefan Schantl stefan.schantl@ipfire.org
src/initscripts/system/functions | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions index 5a26aef45..b610143ab 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -883,3 +883,11 @@ running_on_oci() { # We are not running on OCI return 1 }
+volume_fs_type() {
- if [ ! -d "${1}" ]; then
- return
- fi
- stat -f --format="%T" ${1}
+}
2.39.2