re-do shutdown operations. Run the scripts if we may; take down carp
authorderaadt <deraadt@openbsd.org>
Fri, 27 Dec 2013 22:15:40 +0000 (22:15 +0000)
committerderaadt <deraadt@openbsd.org>
Fri, 27 Dec 2013 22:15:40 +0000 (22:15 +0000)
unconditionally, and then do the optional powerdown
discussed at length with rpe

etc/rc

diff --git a/etc/rc b/etc/rc
index f136d4d..961052b 100644 (file)
--- a/etc/rc
+++ b/etc/rc
@@ -1,4 +1,4 @@
-#      $OpenBSD: rc,v 1.412 2013/12/27 04:21:48 deraadt Exp $
+#      $OpenBSD: rc,v 1.413 2013/12/27 22:15:40 deraadt Exp $
 
 # System startup script run by init on autoboot
 # or after single-user.
@@ -233,33 +233,33 @@ if [ X"$1" = X"shutdown" ]; then
        dd if=/dev/random of=/var/db/host.random bs=65536 count=1 >/dev/null 2>&1
        chmod 600 /var/db/host.random >/dev/null 2>&1
        _c=$?
-       if [ ${_c} -eq 0 -a -n "${pkg_scripts}" ]; then
-               echo -n 'stopping package daemons:'
-               while [ -n "${pkg_scripts}" ]; do
-                       _r=${pkg_scripts##* }
-                       pkg_scripts=${pkg_scripts%%*( )${_r}}
-                       [ -x /etc/rc.d/${_r} ] && /etc/rc.d/${_r} stop
-               done
-               echo '.'
-       fi
-       if [ ${_c} -eq 0 -a -f /etc/rc.shutdown ]; then
+       if [ ${_c} -eq 0 ]; then
+               if [ -n "${pkg_scripts}" ]; then
+                       echo -n 'stopping package daemons:'
+                       while [ -n "${pkg_scripts}" ]; do
+                               _r=${pkg_scripts##* }
+                               pkg_scripts=${pkg_scripts%%*( )${_r}}
+                               [ -x /etc/rc.d/${_r} ] && /etc/rc.d/${_r} stop
+                       done
+                       echo '.'
+               fi
+
                echo /etc/rc.shutdown in progress...
                . /etc/rc.shutdown
                echo /etc/rc.shutdown complete.
+       else
+               echo single user: not running shutdown scripts
+       fi
 
-               # bring carp interfaces down gracefully
-               ifconfig | while read a b; do
-                       case $a in
-                       carp+([0-9]):) ifconfig ${a%:} down ;;
-                       esac
-               done
-
-               if [ X"${powerdown}" = X"YES" ]; then
-                       exit 2
-               fi
+       # bring carp interfaces down gracefully
+       ifconfig | while read a b; do
+               case $a in
+               carp+([0-9]):) ifconfig ${a%:} down ;;
+               esac
+       done
 
-       else
-               echo single user: not running /etc/rc.shutdown
+       if [ X"${powerdown}" = X"YES" ]; then
+               exit 2
        fi
        exit 0
 fi