<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>112991</bug_id>
          
          <creation_ts>2005-11-19 06:07 0000</creation_ts>
          <short_desc>shutdown and reboot fix when not running under sysv style init</short_desc>
          <delta_ts>2006-12-12 03:16:41 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>baselayout</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>benkstein@gmx.de</reporter>
          <assigned_to>base-system@gentoo.org</assigned_to>
          

      

      
          <long_desc isprivate="0">
            <who>benkstein@gmx.de</who>
            <bug_when>2005-11-19 06:07:23 0000</bug_when>
            <thetext>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&apos;s kind of odd ...
-# so let&apos;s force a reboot
-/sbin/reboot -f
+if [ -p /dev/initctl ] ; then
+    /sbin/reboot -idp
+    
+    # hmm, if the above failed, that&apos;s kind of odd ...
+    # so let&apos;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&apos;s kind of odd ...
-# so let&apos;s force a halt
-/sbin/halt -f
+if [ -p /dev/initctl ] ; then
+    /sbin/halt -ihdp
+    
+    # hmm, if the above failed, that&apos;s kind of odd ...
+    # so let&apos;s force a halt
+    /sbin/halt -f
+fi

Please apply.

Thanks in advance
Frank Benkstein.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2005-11-27 10:19:03 0000</bug_when>
            <thetext>thats not really a valid test ... the fifo may exist even when sysvinit is not
being used</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>benkstein@gmx.de</who>
            <bug_when>2006-03-10 00:23:52 0000</bug_when>
            <thetext>What about the check being 

fuser /dev/initctl 2&gt;/dev/null | grep &apos;\&lt;1\&gt;&apos;

? Would that be ok?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>uberlord@gentoo.org</who>
            <bug_when>2006-10-22 10:14:31 0000</bug_when>
            <thetext>A better test would be checking that init owns pid 1

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

Would that be acceptable?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2006-10-23 00:34:56 0000</bug_when>
            <thetext>not really ... if someone doesnt install sysvinit and their own init installs as /sbin/init ...</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>uberlord@gentoo.org</who>
            <bug_when>2006-10-23 00:40:41 0000</bug_when>
            <thetext>Well, we could reverse the test then

if [[ $(pidof /sbin/runit 2&gt;/dev/null) != &quot;1&quot; ]] ; then</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>benkstein@gmx.de</who>
            <bug_when>2006-10-23 07:39:05 0000</bug_when>
            <thetext>I don&apos;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.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2006-10-23 10:23:34 0000</bug_when>
            <thetext>&gt; if [[ $(pidof /sbin/runit 2&gt;/dev/null) != &quot;1&quot; ]] ; 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</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>uberlord@gentoo.org</who>
            <bug_when>2006-10-24 12:08:57 0000</bug_when>
            <thetext>(In reply to comment #7)
&gt; i really dont want to go down that path ... then every other non-sysv init user
&gt; will be clamoring about their $FAVORITE_INIT and for us to add support ... just
&gt; 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&apos;s don&apos;t use them.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2006-10-25 20:12:26 0000</bug_when>
            <thetext>good idea ... i&apos;ll take care of it</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>benkstein@gmx.de</who>
            <bug_when>2006-10-26 06:33:26 0000</bug_when>
            <thetext>This is only a fix if baselayout depends on virtual/init or something like this.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>vapier@gentoo.org</who>
            <bug_when>2006-10-26 12:26:08 0000</bug_when>
            <thetext>no, it&apos;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</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>uberlord@gentoo.org</who>
            <bug_when>2006-12-12 03:16:41 0000</bug_when>
            <thetext>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.</thetext>
          </long_desc>
      
    </bug>

</bugzilla>