-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Init scripts doesn't work for Debian + OpenRC setup. #8204
Comments
@kpande My point is that the if condition used to select sysvinit/openrc code branches is not complete. It enters a wrong code branch in Debian's case, where openrc is installed and detected, but the actuall init is still sysvinit instead of openrc. I'll test my proposed patch in a virtual machine. Should I submit a PR if the result looks good for Debian? sysvinit/openrc is indeed not the first class init system of Debian, but to some extent such init diversity is good to have. update: The proposed patch has been verified on my Debian vm, which selected the correct code branch for Debian+Openrc. If you think this patch is acceptable, I can also setup Gentoo and test it to see if I broke anything. |
nak from gentoo. gentoo does not use
again, the script checks for |
your problem seems to be that the script assumes it should be run by |
@gyakovlev Yes. For Debian+sysvinit+openrc, it should enter the |
on gentoo system the shebang of the file is not sure what is the correct way of detecting if the script is really run under openrc as service manager, I'll check it and report back. we need to make sure it works in all scenarios: gentoo-sysvinit, gentoo-openrc-init, debian-sysvinit, debian-openrc, and it makes me want just create gentoo-only initscripts and don't use this fragile hackery. |
@cdluminate
This is the cause of this bug, the shebang of this script in Debian is
It does not matter what PID 1 you have. Therefore you are facing with only 2 cases here: |
yeah, I haven't used debian for a while, thanks for clarification.
true, I meant is the script should not make assumptions about init, but pick up correct service manager and not guess by checking if file exists. Like you said it can exists but be unused.
it may be a symptom, not the cause, it depends how debian wants to run the script. looks like Makefile makes (no pun intended) some assumptions about openrc the same way as initscript I guess the if zfs package is built on a system without openrc shebang is set to @cdluminate @heroxbd can you help me understand how exactly openrc is used on debian in your case? my current thoughts are that the script should: any ideas how to correctly check the caller of the script in POSIX |
It only replaces
This looks good to me and should be able to solve this issue.
If we stick to the above assumption, we can simply check the |
How about this patch? Index: zfs/etc/init.d/zfs-import.in
===================================================================
--- zfs.orig/etc/init.d/zfs-import.in
+++ zfs/etc/init.d/zfs-import.in
@@ -308,8 +308,7 @@ do_start()
# ----------------------------------------------------
-if [ ! -e /sbin/openrc-run ]
-then
+if ! (echo @SHELL@ | grep openrc 1>/dev/null 2>/dev/null); then
case "$1" in
start)
do_start
Index: zfs/etc/init.d/zfs-mount.in
===================================================================
--- zfs.orig/etc/init.d/zfs-mount.in
+++ zfs/etc/init.d/zfs-mount.in
@@ -199,8 +199,7 @@ do_stop()
# ----------------------------------------------------
-if [ ! -e /sbin/openrc-run ]
-then
+if ! (echo @SHELL@ | grep openrc 1>/dev/null 2>/dev/null); then
case "$1" in
start)
do_start
Index: zfs/etc/init.d/zfs-share.in
===================================================================
--- zfs.orig/etc/init.d/zfs-share.in
+++ zfs/etc/init.d/zfs-share.in
@@ -58,7 +58,7 @@ do_stop()
# ----------------------------------------------------
-if [ ! -e /sbin/openrc-run ]; then
+if ! (echo @SHELL@ | grep openrc 1>/dev/null 2>/dev/null); then
case "$1" in
start)
do_start
Index: zfs/etc/init.d/zfs-zed.in
===================================================================
--- zfs.orig/etc/init.d/zfs-zed.in
+++ zfs/etc/init.d/zfs-zed.in
@@ -98,7 +98,7 @@ do_reload()
# ----------------------------------------------------
-if [ ! -e /sbin/openrc-run ]; then
+if ! (echo @SHELL@ | grep openrc 1>/dev/null 2>/dev/null); then
case "$1" in
start)
do_start |
This issue has been automatically marked as "stale" because it has not had any activity for a while. It will be closed in 90 days if no further activity occurs. Thank you for your contributions. |
Applying such a support upstream would introduce concerns for Gentoo users, and upstream has limited interest on supporting OpenRC for an alternative distribution other than Gentoo. Ref: openzfs/zfs#8204
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. Autoconf has the necessary functions to do substitution, removing one level of indirection for deferring them to `make`. Restrict the substitution in the Makefile to the dedicated list. This construct is inspired by Mo Zhou's runtime detection of the execution shell, but is cleaner to the end users by handling the boilerplate at build time. Reference: openzfs#8063 Reference: openzfs#8204 Reference: openzfs#8359 Signed-off-by: Benda Xu <orv@debian.org>
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: openzfs#8063 Reference: openzfs#8204 Reference: openzfs#8359 Signed-off-by: Benda Xu <orv@debian.org>
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. As of 2024, the initscripts are mostly relevant on Debian, Gentoo and their derivatives. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Benda Xu <orv@debian.org> Issue #8063 Issue #8204 Issue #8359 Closes #15977
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. As of 2024, the initscripts are mostly relevant on Debian, Gentoo and their derivatives. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Benda Xu <orv@debian.org> Issue #8063 Issue #8204 Issue #8359 Closes #15977
System information
Describe the problem you're observing
Unlike Gentoo, Debian doesn't use
/sbin/openrc-init
as the pid1, but still use the init program fromsysvinit-core
. As a result, executing init scripts in the openrc way on Debian won't work, that because e.g. https://github.com/zfsonlinux/zfs/blob/master/etc/init.d/zfs-zed.in#L101 assumes the system pid1 is openrc once the/sbin/openrc-run
is detected, and sysvinit doesn't understand the openrc way.A dirty hack is provided in #8063 which works quite well for both Debian+sysvinit and Debian+openrc setups. A better solution requires us to detect the actual init program type. According to https://unix.stackexchange.com/questions/18209/detect-init-system-using-the-shell , a possible solution may look like
Describe how to reproduce the problem
Include any warning/errors/backtraces from the system logs
None, but zpools will no longer be automatically imported.
The text was updated successfully, but these errors were encountered: