From dc5300a1d2c2f0ee12cd175608c0977ebe6116cb Mon Sep 17 00:00:00 2001 From: Will Miles Date: Wed, 29 Jul 2015 18:55:19 -0400 Subject: [PATCH 1/2] Lift mountpoint name mangling function to functions.sh.in --- init.d/mount.in | 3 +-- sh/functions.sh.in | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/init.d/mount.in b/init.d/mount.in index f2fcd7539..a2805ebe0 100644 --- a/init.d/mount.in +++ b/init.d/mount.in @@ -103,8 +103,7 @@ generate() case "$fsopts" in *noauto*) ;; *) - local name="${fs#/}" - name="$(echo $name | sed 's#/#.#g')" + local name="$(_mountpoint_to_mountname $fs)" einfo ln -snf mount "${svcpath}/${name}" rc=$? [ $rc -ne 0 ] && break diff --git a/sh/functions.sh.in b/sh/functions.sh.in index e4e69eb7b..5d4b773fa 100644 --- a/sh/functions.sh.in +++ b/sh/functions.sh.in @@ -63,6 +63,11 @@ _sanitize_path() echo "$path" } +_mountpoint_to_mountname() +{ + echo ${*#/} | sed 's#/#.#g' +} + # Allow our scripts to support zsh if [ -n "$ZSH_VERSION" ]; then emulate sh From b9f4ac63bed12846d0bf1c301175dffd733bd4ce Mon Sep 17 00:00:00 2001 From: Will Miles Date: Wed, 29 Jul 2015 18:59:11 -0400 Subject: [PATCH 2/2] Add 'path' depend() keyword This patch adds a new 'path' keyword for depend() blocks. When invoked, it resolves the path name specified to the mounted filesystem, and emits a need line for the relevant mount.fs service. TODO: documentation --- sh/gendepends.sh.in | 13 +++++++++++++ sh/openrc-run.sh.in | 5 ++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/sh/gendepends.sh.in b/sh/gendepends.sh.in index dfe7444b3..360a0688a 100644 --- a/sh/gendepends.sh.in +++ b/sh/gendepends.sh.in @@ -28,6 +28,19 @@ provide() { keyword() { [ -n "$*" ] && echo "$RC_SVCNAME keyword $*" >&3 } +path() { + # Resolve each entry into an ineed line on a mountpoint + [ -n "$*" ] || return + for PATHNAME in *; do + # We loop here because some systems (QNX) can have multiple fs's backing a mountpoint + # The sed line chops off the + df -P $PATHNAME | sed 1d | while read one two three four five six; do + # borrowed from mount's generate: should go somewhere higher up as a function + local name="$(_mountpoint_to_mountname $six)" + [ -n "$name" ] && echo "$RC_SVCNAME ineed mount.$name" >&3 + done + done # for PATHNAME +} depend() { : } diff --git a/sh/openrc-run.sh.in b/sh/openrc-run.sh.in index 33dc59c59..3b0c619d2 100644 --- a/sh/openrc-run.sh.in +++ b/sh/openrc-run.sh.in @@ -78,6 +78,9 @@ provide() { keyword() { [ -n "$*" ] && echo "keyword $*" } +path() { + [ -n "$*" ] && echo "path $*" +} # Describe the init script to the user describe() @@ -217,7 +220,7 @@ for _cmd; do break fi done - + # Load our script sourcex "$RC_SERVICE"