On Tue, Feb 17, 2015 at 01:20:03PM +0000, Craig Skinner wrote:
> Produces (on 5.6 release) - with start up order reversed:
> 
> <root@box:~ 0># halt -p
> stopping package daemons: greyscanner postfix sshguard.
> stopping base daemons: cron spamlogd spamd sshd ntpd unbound nsd pflogd 
> syslogd.
> syncing disks... done

I cooked a patch for that a few months ago (actually >1 year ago iirc) but we 
decided not to go down that road for a reason I cannot recall right now.
And I was using the information from /var/run/rc.d instead to know what to 
shutdown exactly instead of greping /etc/rc.

> Index: rc
> ===================================================================
> RCS file: /cvs/src/etc/rc,v
> retrieving revision 1.447
> diff -u -p -r1.447 rc
> --- rc        22 Jan 2015 19:00:24 -0000      1.447
> +++ rc        17 Feb 2015 13:16:05 -0000
> @@ -131,17 +131,42 @@ fill_baddynamic()
>       }
>  }
>  
> -start_daemon()
> +start_stop_daemon()
>  {
> -     local _n
> -     for _n; do
> -             eval _do=\${${_n}_flags}
> -             if [ X"${_do}" != X"NO" ]; then
> -                     /etc/rc.d/${_n} start
> -             fi
> +     local _start_stop=$1
> +     local _daemon _daemon_script
> +     shift
> +
> +     for _daemon
> +     do
> +             eval _do=\${${_daemon}_flags}
> +             [[ ${_do} == 'NO' ]] && continue
> +
> +             _daemon_script="/etc/rc.d/${_daemon}"
> +             [[ -e ${_daemon_script} ]] ||
> +             {
> +                     print -n -- " ${_daemon}(absent)"
> +                     continue
> +             }
> +             [[ -x ${_daemon_script} ]] ||
> +             {
> +                     print -n -- " ${_daemon}(inexecutable)"
> +                     continue
> +             }
> +             ${_daemon_script} ${_start_stop}
>       done
>  }
>  
> +start_daemon()
> +{
> +     start_stop_daemon 'start' $*
> +}
> +
> +stop_daemon()
> +{
> +     start_stop_daemon 'stop' $*
> +}
> +
>  make_keys()
>  {
>       if [ ! -f /etc/isakmpd/private/local.key ]; then
> @@ -269,12 +294,24 @@ if [ X"$1" = X"shutdown" ]; then
>                       while [ -n "${pkg_scripts}" ]; do
>                               _r=${pkg_scripts##* }
>                               pkg_scripts=${pkg_scripts%%*( )${_r}}
> -                             [ -x /etc/rc.d/${_r} ] && /etc/rc.d/${_r} stop
> +                             stop_daemon ${_r}
>                       done
>                       echo '.'
>               fi
>  
>               [ -f /etc/rc.shutdown ] && sh /etc/rc.shutdown
> +
> +             print -n 'stopping base daemons:'
> +             _daemons=$(egrep "start_daemon[[:blank:]][[:alnum:]]" /etc/rc |
> +                     sed s"/start_daemon//")
> +             while [[ -n ${_daemons} ]]
> +             do
> +                     _daemon=${_daemons##* }
> +                     _daemons=${_daemons%%*( )${_daemon}}
> +                     stop_daemon ${_daemon}
> +             done
> +             print '.'
> +
>       else
>               echo single user: not running shutdown scripts
>       fi
> @@ -513,11 +550,7 @@ rm -f /etc/rc.firsttime.run
>  if [ -n "${pkg_scripts}" ]; then
>       echo -n 'starting package daemons:'
>       for _r in $pkg_scripts; do
> -             if [ -x /etc/rc.d/${_r} ]; then
> -                     start_daemon ${_r}
> -             else
> -                     echo -n " ${_r}(absent)"
> -             fi
> +             start_daemon ${_r}
>       done
>       echo '.'
>  fi
> 

-- 
Antoine

Reply via email to