On Sunday 21 September 2008 20:53:13 Neil Bothwick wrote: > On Sun, 21 Sep 2008 18:34:15 +0100, Robert Bridge wrote: > > > Like having a /etc/hosts.home and a /etc/hosts.world and a script > > > that sysmlinks them to /etc/hosts depending on the fact that i can > > > ping or not 192.168.1.5? > > > > Basically, I would probably look at methods of hooking it onto the IP > > assigned to the device (ifplugd should be able to do this), but that is > > the basic idea. > > You could do it in the postup function of /etc/conf.d/net.
Right I made 2 scripts:
/root/scripts/hosts.world
#!/bin/bash
MYFILE='/etc/hosts.backup'
OLDHOST=`grep fandango $MYFILE | awk '{ print $1 }'`
NEWHOST=`host fandango.dyndns.foo | gawk '{print $4}'`
sed s/$OLDHOST/$NEWHOST/ $MYFILE > /etc/hosts
/root/scripts/hosts.home
#!/bin/bash
MYFILE='/etc/hosts.backup'
OLDHOST=`grep fandango $MYFILE | awk '{ print $1 }'`
NEWHOST=192.168.1.5
sed s/$OLDHOST/$NEWHOST/ $MYFILE > /etc/hosts
Then I added a postup function in /etc/conf.d/net
postup() {
if [[ ${IFACE} == "ppp1" ]] ; then
/root/scripts/hosts.home
elif [[ ${IFACE} == "ppp2" ]] ; then
/root/scripts/hosts.world
fi
return 0
}
It works like a charm :)
--
========================================
MOMESSO ANDREA
jabber: [EMAIL PROTECTED]
========================================
signature.asc
Description: This is a digitally signed message part.

