[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: start daemons according to current runlevel upon upgrade



> I have created two scripts named start-rc.d. One for runlevel links and
> one for file-rc. I think, they should be included in the corresponding
> packages which contain the update-rc.d skript (dpkg and file-rc).

Firstly, see bug#20373 where this is discussed.  A policy change would
be worthwhile.

I would recommend start-stop-service as a name, parallelling
start-stop-daemon and you need the following logic, not including
error checking (and you beat me to it by just a couple of days);
remember that you need to check /etc/rcS.d as well!

<copy startup() from /etc/init.d/rc>
<baulk if #args!=2>
PATH=/usr/sbin:/sbin

service=$1
op=$2
runlevel=`runlevel`

case "$2" in
  start|restart|reload|force-reload)
    start=/etc/rc$runlevel.d/S[0-9][0-9]$service
    stop=/etc/rc$runlevel.d/K[0-9][0-9]$service
    rcS_start=/etc/rcS.d/S[0-9][0-9]$service

    # Check whether the daemon should be started
    if [ -f $start ]; then startup $i $2
    elseif [ -f $rcS_start ] && [ ! -f $stop ]; then startup $i $2
    fi
    ;;
  stop)
    [ -f /etc/init.d/$service ] && /etc/init.d/$service stop
    ;;
esac

Note that this assumes that /etc/init.d/$service won't fall over if
you stop a stopped daemon or start a started one; this should probably
be made a policy requirement.

David Damerell and I have also been talking about ways of suspending
services, and will probably post some ideas in the next couple of
days.

   Julian

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  Julian Gilbey, Dept of Maths, QMW, Univ. of London. J.D.Gilbey@qmw.ac.uk
        Debian GNU/Linux Developer,  see http://www.debian.org/~jdg


Reply to: