On 2012-09-02 15:26, nrickert wrote:
>
> I’m not sure why you even need that line. My laptop works fine without
> their LAN ip in the hosts file.
One item does not: postfix. And I use postfix to do the mail sending, instead of directly from
thunderbird, because sometimes I use Pine instead.
> I shall assume that the hostname “minas-tirith” is fixed, and that the
> IP address is in shell variable “$IP”.
>
> Try:
>
> Code:
> --------------------
>
> cp /etc/hosts /etc/hosts.old
> sed -e ‘/minas-tirith/s=^[0-9.]*=’"$IP"’=’ /etc/hosts.old > /etc/hosts
>
> --------------------
Yes, that appears to work, I tried on a temporary file 
Thanks! 
Now my next problem is that ip-up is not executing ip-up.local :-/
Ah, it is, but silently. I added logger commands to see my way.
This is the ip-up.local script. Do you see a problem there?
I started by copying the system ip-up script and removed almost all.
#!/bin/bash
unset POSIXLY_CORRECT ; set +o posix # we're using non-posix bash features
BASENAME=${0##*/}
INTERFACE=$1
DEVICE=$2
SPEED=$3
LOCALIP=$4
REMOTEIP=$5
IPPARAM=$6
# send all output to syslog
#exec > >(logger -p security.notice -t "$BASENAME") 2>&1
#TERM=raw
#export TERM
logger -p security.notice "inside .local $INTERFACE $DEVICE"
case "$BASENAME" in
*-up)
logger -p security.notice "inside up.local $INTERFACE $DEVICE"
if $INTERFACE = "ppp0" ]; then
# All conectar con Yoigo la IP local varía, y postfix no funciona bien.
cp /etc/hosts /etc/hosts.old
sed -e '/minas-tirith/s=^[0-9\.]*='"$IP"'=' /etc/hosts.old > /etc/hosts
rcpostfix reload
fi
;;
esac
The log entry says:
Sep 2 19:46:53 minas-tirith logger: inside .local ip-up.local ppp0 /dev/ttyUSB1
Thus basename is not matching, I don’t see the second entry. Ah, of course, the “local” part. Ok,
now the script works!
It is now:
case "$BASENAME" in
*-up.local)
logger -p security.notice "inside up.local $INTERFACE $DEVICE"
if $INTERFACE = "ppp0" ]; then
# All conectar con Yoigo la IP local varía, y postfix no funciona bien.
cp /etc/hosts /etc/hosts.old
sed -e '/minas-tirith/s=^[0-9\.]*='"$LOCALIP"'=' /etc/hosts.old > /etc/hosts
/sbin/rcpostfix reload
fi
;;
esac
Interesting, I see the errors just after I copy them here to send 
–
Cheers / Saludos,
Carlos E. R.
(from 11.4 x86_64 “Celadon” (Minas Tirith))