Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 112991 - shutdown and reboot fix when not running under sysv style init
Summary: shutdown and reboot fix when not running under sysv style init
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-19 06:07 UTC by Frank Benkstein
Modified: 2006-12-12 03:16 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frank Benkstein 2005-11-19 06:07:23 UTC
Hi,

/etc/init.d/{reboot,shutdown}.sh asume that they are running under a sysv style
init. This this makes reboot and sometimes also shutdown fail when running with
runit as a init replacement. Following small fix should have no impact on normal
systems but makes reboot and shutdown with runit work as expected:

--- ._cfg0000_reboot.sh 2005-11-13 05:09:38.000000000 +0000
+++ reboot.sh   2005-11-19 16:03:46.000000000 +0000
@@ -1,8 +1,10 @@
 # Copyright 1999-2005 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-/sbin/reboot -idp
-
-# hmm, if the above failed, that's kind of odd ...
-# so let's force a reboot
-/sbin/reboot -f
+if [ -p /dev/initctl ] ; then
+    /sbin/reboot -idp
+    
+    # hmm, if the above failed, that's kind of odd ...
+    # so let's force a reboot
+    /sbin/reboot -f
+fi

--- ._cfg0000_shutdown.sh       2005-11-13 05:09:38.000000000 +0000
+++ shutdown.sh 2005-11-19 16:03:44.000000000 +0000
@@ -1,8 +1,10 @@
 # Copyright 1999-2005 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
-/sbin/halt -ihdp
-
-# hmm, if the above failed, that's kind of odd ...
-# so let's force a halt
-/sbin/halt -f
+if [ -p /dev/initctl ] ; then
+    /sbin/halt -ihdp
+    
+    # hmm, if the above failed, that's kind of odd ...
+    # so let's force a halt
+    /sbin/halt -f
+fi

Please apply.

Thanks in advance
Frank Benkstein.
Comment 1 SpanKY gentoo-dev 2005-11-27 10:19:03 UTC
thats not really a valid test ... the fifo may exist even when sysvinit is not
being used
Comment 2 Frank Benkstein 2006-03-10 00:23:52 UTC
What about the check being 

fuser /dev/initctl 2>/dev/null | grep '\<1\>'

? Would that be ok?
Comment 3 Roy Marples (RETIRED) gentoo-dev 2006-10-22 10:14:31 UTC
A better test would be checking that init owns pid 1

if [[ $(pidof /sbin/init) == "1" ]] ; then
    halt or reboot code
fi

Would that be acceptable?
Comment 4 SpanKY gentoo-dev 2006-10-23 00:34:56 UTC
not really ... if someone doesnt install sysvinit and their own init installs as /sbin/init ...
Comment 5 Roy Marples (RETIRED) gentoo-dev 2006-10-23 00:40:41 UTC
Well, we could reverse the test then

if [[ $(pidof /sbin/runit 2>/dev/null) != "1" ]] ; then
Comment 6 Frank Benkstein 2006-10-23 07:39:05 UTC
I don't see what is bad about checking whether /dev/initctl exists,
is a pipe, and is used by process id 1. That is exactly what sysvinit
is doing.
Comment 7 SpanKY gentoo-dev 2006-10-23 10:23:34 UTC
> if [[ $(pidof /sbin/runit 2>/dev/null) != "1" ]] ; then

i really dont want to go down that path ... then every other non-sysv init user will be clamoring about their $FAVORITE_INIT and for us to add support ... just look at the mess that is /etc/init.d/clock
Comment 8 Roy Marples (RETIRED) gentoo-dev 2006-10-24 12:08:57 UTC
(In reply to comment #7)
> i really dont want to go down that path ... then every other non-sysv init user
> will be clamoring about their $FAVORITE_INIT and for us to add support ... just
> look at the mess that is /etc/init.d/clock

Well, we could punt shutdown.sh and reboot.sh to the sysvinit ebuild - which makes sense as the BSD's don't use them.
Comment 9 SpanKY gentoo-dev 2006-10-25 20:12:26 UTC
good idea ... i'll take care of it
Comment 10 Frank Benkstein 2006-10-26 06:33:26 UTC
This is only a fix if baselayout depends on virtual/init or something like this.
Comment 11 SpanKY gentoo-dev 2006-10-26 12:26:08 UTC
no, it's a proper fix regardless

if you want to persue a virtual/init you could post it to the gentoo-dev list ... not that i see any issue with it
Comment 12 Roy Marples (RETIRED) gentoo-dev 2006-12-12 03:16:41 UTC
baselayout-1.12.7 and 1.13.0_alpha9 now depend on virtual init which by default uses sysvinit which now provides reboot and shutdown scripts.