1 |
On Sunday 21 September 2008 20:53:13 Neil Bothwick wrote: |
2 |
> On Sun, 21 Sep 2008 18:34:15 +0100, Robert Bridge wrote: |
3 |
> > > Like having a /etc/hosts.home and a /etc/hosts.world and a script |
4 |
> > > that sysmlinks them to /etc/hosts depending on the fact that i can |
5 |
> > > ping or not 192.168.1.5? |
6 |
> > |
7 |
> > Basically, I would probably look at methods of hooking it onto the IP |
8 |
> > assigned to the device (ifplugd should be able to do this), but that is |
9 |
> > the basic idea. |
10 |
> |
11 |
> You could do it in the postup function of /etc/conf.d/net. |
12 |
|
13 |
Right I made 2 scripts: |
14 |
|
15 |
/root/scripts/hosts.world |
16 |
|
17 |
#!/bin/bash |
18 |
MYFILE='/etc/hosts.backup' |
19 |
OLDHOST=`grep fandango $MYFILE | awk '{ print $1 }'` |
20 |
NEWHOST=`host fandango.dyndns.foo | gawk '{print $4}'` |
21 |
sed s/$OLDHOST/$NEWHOST/ $MYFILE > /etc/hosts |
22 |
|
23 |
/root/scripts/hosts.home |
24 |
|
25 |
#!/bin/bash |
26 |
MYFILE='/etc/hosts.backup' |
27 |
OLDHOST=`grep fandango $MYFILE | awk '{ print $1 }'` |
28 |
NEWHOST=192.168.1.5 |
29 |
sed s/$OLDHOST/$NEWHOST/ $MYFILE > /etc/hosts |
30 |
|
31 |
Then I added a postup function in /etc/conf.d/net |
32 |
|
33 |
postup() { |
34 |
if [[ ${IFACE} == "ppp1" ]] ; then |
35 |
/root/scripts/hosts.home |
36 |
elif [[ ${IFACE} == "ppp2" ]] ; then |
37 |
/root/scripts/hosts.world |
38 |
fi |
39 |
return 0 |
40 |
} |
41 |
|
42 |
It works like a charm :) |
43 |
|
44 |
|
45 |
-- |
46 |
======================================== |
47 |
MOMESSO ANDREA |
48 |
jabber: topper_harley@××××××.org |
49 |
======================================== |