On Tue, Sep 27, 2005 at 12:31:36PM +0200, Hermann Lauer wrote: > Hello Andrew,
Hi, Sorry for the late reply. I've been digesting what you've written, and mulling over it. > 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. > So, how does this sound...? If run_hook() is called with the name of the script and then all the arguments (i.e. $*) that dhclient-script was called with, then run_hook() has access to all the arguments. Simply shifting once will throw away the name of the hook, and make $1 the first argument that dhclient-script was called with. If you could please substitute your doctored dhclient-script with what's at http://people.debian.org/~apollock/dhcp3/dhclient-script and let me know if I'm on the right track or not, that'd be great. regards Andrew -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]