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 62487c3..13b4fb8 100644
--- a/sh/openrc-run.sh.in
+++ b/sh/openrc-run.sh.in
@@ -361,7 +361,16 @@ if [ "$1" = depend ]; then
 
 	return 0
 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
 
 	return 0
