man 5 ifstated.conf says:

"The init block is used
to initialise the state and is executed each time the
state is entered."

But this does not seem to be true if you use 'init-state'
to enter the state.  Or maybe there's something else
wrong with my config below, or with ifstated when there's
no body.  Or something.

Odd things happen with the following ifstated.conf.
It just hangs out in the state "starting".
(Starting the daemon by hand after booting.)
Things go back in sync after a state change on
carp0.  (carp0 starts out in MASTER.  Unpugging
the cable sends it into BACKUP.  At that time
ifstated first changes state to 'master', and
then immediately to 'not_master'.)

OTOH, the given config works just fine if
you remove the "init {" and "}" from the "starting"
state, leaving the action as the body of the "starting".
I would expect the opposite, that without "init" the state would
stay in "starting" and have to wait for a state
change before the body was evaluated.

So, it seems that ifstated with "init-state" executes
the body of the inital state on startup, and ignores the
"init" block.

/etc/ifstated.conf:
# Reconfigures daemons based on whether we're master or not.

# We want to startup
init-state starting

# net.inet.carp.preempt must be enabled (set to 1)
# for this to work correctly.

carp_up = "carp0.link.up"

state starting {
       init {
                # Here we boot the box.
                if $carp_up
                        set-state master
                if ! $carp_up
                        set-state not_master
            }
}

state not_master {
        init {
                run "rm /tmp/am_master"
        }
        if $carp_up
                set-state master
}

state master {
        init {
                run "touch /tmp/am_master"
        }
        if ! $carp_up
                set-state not_master
}


Karl <[EMAIL PROTECTED]>
Free Software:  "You don't pay back, you pay forward."
                 -- Robert A. Heinlein

Reply via email to