1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
From: Gabriele Giacone <1o5g4r8o@gmail.com>
Date: Wed, 4 Jan 2017 21:42:01 +0900
Subject: consider-initd-shebangs
Description: Allow non-sh shebang in init.d scripts.
If /bin/sh is not detected in initscript shebang, to avoid for instance
bashisms /bin/sh can't understand, runscript re-runs itself with non-sh
shell. This workarounds failures starting non-sh initscript.
---
sh/openrc-run.sh.in | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/sh/openrc-run.sh.in b/sh/openrc-run.sh.in
index 25d1d2a..ef95197 100644
--- a/sh/openrc-run.sh.in
+++ b/sh/openrc-run.sh.in
@@ -335,7 +335,16 @@ while [ -n "$1" ]; do
cd /
continue
elif [ -n "${lsbh}" ]; then
- . "${RC_SERVICE}"
+ read -r shebang < "${RC_SERVICE}"
+ case "${shebang}" in
+ *runscript*|*openrc-run*)
+ . "${RC_SERVICE}"
+ ;;
+ *)
+ . /etc/profile # Reset to vanilla PATH
+ exec "${RC_SERVICE}" $*
+ ;;
+ esac
shift
continue
fi
|