Skip to content

Commit ff72a0e

Browse files
author
Benda Xu
committed
etc/init.d: decide which variant to use at build time.
Let Debian use the sysv-rc variant of the script, even when OpenRC is installed. Unlike on Gentoo, OpenRC on Debian consumes both the sysv-rc scripts and OpenRC ones. ZFS initscripts on Debian should be the sysv-rc version to provide most compatibility and to integrate with the rest of initscripts for dependency tracking. Restrict the substitution in the Makefile to the dedicated list. This construct is inspired by Mo Zhou's detection of the execution shell and follows the strategy of Peter in 6ef28c5. Reference: #8063 Reference: #8204 Reference: #8359 Signed-off-by: Benda Xu <[email protected]>
1 parent 8f2f6cd commit ff72a0e

File tree

7 files changed

+13
-8
lines changed

7 files changed

+13
-8
lines changed

config/Substfiles.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ subst_sed_cmd = \
1818
-e 's|@ASAN_ENABLED[@]|$(ASAN_ENABLED)|g' \
1919
-e 's|@DEFAULT_INIT_NFS_SERVER[@]|$(DEFAULT_INIT_NFS_SERVER)|g' \
2020
-e 's|@DEFAULT_INIT_SHELL[@]|$(DEFAULT_INIT_SHELL)|g' \
21+
-e 's|@IS_SYSV_RC[@]|$(IS_SYSV_RC)|g' \
2122
-e 's|@LIBFETCH_DYNAMIC[@]|$(LIBFETCH_DYNAMIC)|g' \
2223
-e 's|@LIBFETCH_SONAME[@]|$(LIBFETCH_SONAME)|g' \
2324
-e 's|@PYTHON[@]|$(PYTHON)|g' \

config/zfs-build.m4

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,13 +578,15 @@ AC_DEFUN([ZFS_AC_DEFAULT_PACKAGE], [
578578
579579
AC_MSG_CHECKING([default shell])
580580
case "$VENDOR" in
581-
gentoo) DEFAULT_INIT_SHELL="/sbin/openrc-run";;
582-
alpine) DEFAULT_INIT_SHELL="/sbin/openrc-run";;
583-
*) DEFAULT_INIT_SHELL="/bin/sh" ;;
581+
gentoo|alpine) DEFAULT_INIT_SHELL=/sbin/openrc-run
582+
IS_SYSV_RC=false ;;
583+
*) DEFAULT_INIT_SHELL=/bin/sh
584+
IS_SYSV_RC=true ;;
584585
esac
585586
586587
AC_MSG_RESULT([$DEFAULT_INIT_SHELL])
587588
AC_SUBST(DEFAULT_INIT_SHELL)
589+
AC_SUBST(IS_SYSV_RC)
588590
589591
AC_MSG_CHECKING([default nfs server init script])
590592
AS_IF([test "$VENDOR" = "debian"],

etc/init.d/zfs-import.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ do_start()
307307

308308
# ----------------------------------------------------
309309

310-
if [ ! -e /sbin/openrc-run ]
310+
if @IS_SYSV_RC@
311311
then
312312
case "$1" in
313313
start)

etc/init.d/zfs-load-key.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ do_stop()
104104

105105
# ----------------------------------------------------
106106

107-
if [ ! -e /sbin/openrc-run ]
107+
if @IS_SYSV_RC@
108108
then
109109
case "$1" in
110110
start)

etc/init.d/zfs-mount.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ do_stop()
114114

115115
# ----------------------------------------------------
116116

117-
if [ ! -e /sbin/openrc-run ]
117+
if @IS_SYSV_RC@
118118
then
119119
case "$1" in
120120
start)

etc/init.d/zfs-share.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ do_stop()
5757

5858
# ----------------------------------------------------
5959

60-
if [ ! -e /sbin/openrc-run ]; then
60+
if @IS_SYSV_RC@
61+
then
6162
case "$1" in
6263
start)
6364
do_start

etc/init.d/zfs-zed.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ do_reload()
9393

9494
# ----------------------------------------------------
9595

96-
if [ ! -e /sbin/openrc-run ]; then
96+
if @IS_SYSV_RC@
97+
then
9798
case "$1" in
9899
start)
99100
do_start

0 commit comments

Comments
 (0)