Re: Executing commands at home and elsewhere



On 6/25/07, Kjetil Kjernsmo <kjetil kjernsmo net> wrote:
Hi and thanks for the quick reply!

I was meaning to start working on it, but the Real World came in and
interferred, anyway, here we go. :-)

On Tuesday 19 June 2007, Darren Albers wrote:
> On 6/19/07, Dan Williams <dcbw redhat com> wrote:

> > There's a tool called NetworkManagerDispatcher that calls scripts
> > in /etc/NetworkManager/dispatcher.d when connections go up and down
> > that most people use for this sort of thing, actually.

> Here is one list (Though it is somewhat short since I haven't seen
> any posted lately):
> http://www.darrenalbers.net/wiki/index.php?title=NetworkManagerScript
>s
>
> I think what you want is to use something whereami in conjunction
> with NetworkManagerDispatcher.

Great stuff, this is what I'm looking for, for sure.

whereami seems to have everything I have looked for in terms of
determining where I am. So, what remains is just executing scripts
depending on the location.

NetworkManagerDispatcher will only execute the scripts in the first
level /etc/NetworkManager/dispatcher.d directory, right, not descend
into subdirs?

So, I was thinking about a setup similar to the Apache 2 setup on my
box, i.e. create /etc/NetworkManager/dispatcher.d/scripts-available
and /etc/NetworkManager/dispatcher.d/scripts-enabled and in the latter
again subdirs for each of the locations, given the same names as in the
whereami config, which would symlink to the actual scripts to be
launched at each location
in /etc/NetworkManager/dispatcher.d/scripts-available

This would allow for relatively straightforward setups in the supposedly
common case that there are several actions that would be in common for
different locations, but not all.

Does that sound like a reasonable approach?

Kjetil
--
Kjetil Kjernsmo
Programmer / Astrophysicist / Ski-orienteer / Orienteer / Mountaineer
kjetil kjernsmo net
Homepage: http://www.kjetil.kjernsmo.net/     OpenPGP KeyID: 6A6A0BBC
_______________________________________________


I vaguely remember that Dispatcher.d doesn't support symlinks, but it
does support calling other scripts from the script itself so something
like:
if [ $2 == "up" ]; then
   /etc/init.d/whereami restart
fi


All you are doing is telling whereami to run when the interface comes
up and letting it handle the rest.  It has been a LONG time since I
have used whereami so any specifics of it are long forgotten but I
remember using it to handle my NFS mounts based on the location I was
visiting.  I am trying to remember how it knew that the network had
changed but whereami may have handled that for me automatically....
If I get some time when I get home I will take a look at whereami's
man pages.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]