Package: insserv
Version: 1.09.0-1

Insserv will some times warn about a dependency loop in the init.d
scripts, even though there is no such loop.  The reason is that it
build a common dependency graph for both the start and stop
sequences. This make sense when all dependencies are required
dependencies, to make sure init.d scripts can be installed in an order
that fulfills dependencies both on shutdown and boot.  It does not
make sense when there are optional dependencies that make it possible
to install both scripts, but the specified dependencies make a
apparent dependency loop because script A depend on script B during
boot, and script B depend on script A during shutdown.

These two dependency headers demonstrate the problem.  Notice how the
stop dependency is optional, and only have effect when startsecond is
installed in the system.

### BEGIN INIT INFO
# Provides:          startfirst
# Required-Start:
# Required-Stop:
# Should-Stop:       startsecond
# Default-Start:     S
# Default-Stop:      6
### END INIT INFO

### BEGIN INIT INFO
# Provides:          startsecond
# Required-Start:    startfirst
# Required-Stop:
# Default-Start:     S
# Default-Stop:      6
### END INIT INFO

Here is a test script to demonstrate the problem:

#!/bin/sh
set -e
tmpdir=`pwd`/testdir
initddir=$tmpdir/init.d
insserv=`pwd`/insserv
overridedir=$tmpdir/insserv/override
retval=0
mkdir -p $initddir
insserv_reg() {
    script=$initddir/$1
    $insserv $debug -p $initddir -o $overridedir $script
}
insertscript() {
    scriptname=$1
    script=$initddir/$scriptname
    cat > $script
    chmod a+rx $script
    insserv_reg $scriptname
}
check_order() {
    runlevel=$1
    script1=$2
    script2=$3
    order="$(echo $(cd $tmpdir/rc$runlevel.d/; ls *$script1 *$script2 
2>/dev/null | sed 's/[SK]..//') )"
    if [ "$order" != "$script1 $script2" ] ; then
        echo "error: incorrect $runlevel sequence $script1 not before $script2"
        retval=1
    fi
}
# Test another fake loop.  This one should work, as it is possible to
# install the two scripts in sequence because one of the dependencies
# are optional.  It does not with insserv today.
rm -rf $initddir
mkdir -p $initddir
insertscript startfirst <<'EOF' || true
### BEGIN INIT INFO
# Provides:          startfirst
# Required-Start:
# Required-Stop:
# Should-Stop:       startsecond
# Default-Start:     S
# Default-Stop:      6
### END INIT INFO
EOF
insertscript startsecond <<'EOF' || true
### BEGIN INIT INFO
# Provides:          startsecond
# Required-Start:    startfirst
# Required-Stop:
# Default-Start:     S
# Default-Stop:      6
### END INIT INFO
EOF
(cd $tmpdir && ls *)
check_order S startfirst startsecond
check_order 6 startsecond startfirst
rm -rf $tmpdir
exit $retval

When executed, it prints this.  Notice the claims of a loop between
startfirst and startsecond, and that the generated sequence is
incorrect.

  insserv: There is a loop between service startfirst and startsecond
  insserv: There is a loop between service startsecond and startfirst
  init.d:
  startfirst  startsecond

  rc0.d:

  rc1.d:

  rc2.d:

  rc3.d:

  rc4.d:

  rc5.d:

  rc6.d:
  K01startfirst  K02startsecond

  rcS.d:
  S02startsecond  S03startfirst
  error: incorrect S sequence startfirst not before startsecond
  error: incorrect 6 sequence startsecond not before startfirst

Happy hacking,
-- 
Petter Reinholdtsen



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to