Hello Andrew,

On Fri, Sep 16, 2005 at 07:57:48PM +1000, Andrew Pollock wrote:
> I've got to say I'm not quite following what you're saying the problem
> is here. I've examined the stock "linux" dhclient-script that ships with
> the source, and I can't see how it's passing any arguments to the hooks
> either.

That's done implicit - see the following lines from 
dhcp-3.0.3/client/scripts/linux bash script:

# Must be used on exit.   Invokes the local dhcp client exit hooks, if any.
exit_with_hooks() {
  exit_status=$1
  if [ -f /etc/dhclient-exit-hooks ]; then
    . /etc/dhclient-exit-hooks
  fi
# probably should do something with exit status of the local script
  exit $exit_status
}

Note they source the exit hooks, so the arguments are preserved
and thus available to /etc/dhclient-exit-hooks. They
even care about storing the argument to keep the exit code intact.

The arg1 is set different with the following code further down:

    exit_with_hooks 0
  fi
  ifconfig $interface inet 0 down
  exit_with_hooks 1

> 
> That said, you talk about detecting failures. I had a quick play with
> the debug hook that ships with the client package, and enabled it, and
> there's a "reason" variable available to it. I tried playing with it,
> but the best I could do is get it to be set to "FAIL", not "TIMEOUT"
> that you speak of.
> 
> So if you can give me an example of how you'd like this to work, I can
> see what I can do.

You have to configure some leases to try without a dhcp server,
then dhcp-client will try to ping the router configured there
and if it is available it will TIMEOUT with a different exit code
to the /etc/dhclient-exit-hooks - so that you can recognise that
your laptop is connected to the home network, for example.

I can give you log files from my laptop, so you can see that this
really works - but maybe this discussion should be taken to the
dhcp-client mailing list. I use a modified dhclient-script which even
did not need a router to be configured, because at my home network
I did'nt want to depend on one machine to be always up. 

The debian bug here is that the arg1 is not propagated trough
that run_script part. My hack at the moment is the follwing:

exit_with_hooks() {
    exit_status=$1
    hook_arg1=$1
...
run_hook() {
...
    if [ -f $script ]; then
        . $script $hook_arg1
    fi
...

So my setup works with this hack, but a bash expert would probably know
a better solution.

Thanks, 
  greetings
   Hermann

-- 
Netzwerkadministration/Zentrale Dienste, Interdiziplinaeres 
Zentrum fuer wissenschaftliches Rechnen der Universitaet Heidelberg
IWR; INF 368; 69120 Heidelberg; Tel: (06221)54-8236 Fax: -5224
Email: [EMAIL PROTECTED]


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

Reply via email to