This one time, at band camp, [EMAIL PROTECTED] said:
> My problem is really starting an arbitrary number...
> 
> Perhaps I am guilty of some abuse of language; sorry. There is only one 
> daemon, which I am trying to start an arbitrary number of copies of, 
> with an arbitrary number of - possibly - different options. I'd like to 
> be able to do something like:
> 
> ---
> for DAEMON_OPTS in $DAEMON_OPTS_LIST; do
>       echo -n " $NAME"
>       start-stop-daemon --start --quiet --pidfile /var/run/$NAME.$i.pid \
>               --exec $DAEMON -- $DAEMON_OPTS
> done
> ---

You want an array of arrays.

The simplest (although there are many other ways to d this, not all are
as easily self documenting or simple to use) is something like:

/etc/default/package:
# Configure here your options for each running daemon:
DAEMON_1_OPTS="..."
DAEMON_2_OPTS="..."
DAEMON_3_OPTS="..."

#(don't use 'export foo=bar here', just regular variable assignments)

/etc/init.d/package:

if [ -f /etc/default/package ] 
  . /etc/default/package
fi

# This cuts any line that is only whitespace, or first non-whitespace
# character is a comment (#), and parses the rest.

DAEMON_OPTS_LIST=`egrep -v '^[[:space:]]*(#|$)' /etc/default/package \
  | awk -F '=' '{print $1}'`

for DAEMON_OPTS in "$DAEMON_OPTS_LIST"; do 
  start-stop-daemon --start --quiet --pidfile /var/run/$NAME.$i.pid \
    --exec $DAEMON -- $DAEMON_OPTS
done

or something.  That would be user configurable and relatively
discoverable.  There are many other bash constructs that do this more
efficiently, but you should try to keep the /etc/default file as
straightforward as possible.  I am still not sure I am addressing your
question fully, but I think so.  I think you want:

single daemon, possibility of running multiple instances
said daemon does not by itself run multiple instances by default 
  (unlike, e.g, apache)
said daemon should have different options on different instances

I think my proposal allows that to happen, and in a user configurable
way.  If that is still not quite what you're looking for, write back -
I'm sure we can dig something else up.
-- 
 -----------------------------------------------------------------
|   ,''`.                                            Stephen Gran |
|  : :' :                                        [EMAIL PROTECTED] |
|  `. `'                        Debian user, admin, and developer |
|    `-                                     http://www.debian.org |
 -----------------------------------------------------------------

Attachment: pgpebnzJGP2xP.pgp
Description: PGP signature

Reply via email to