--- SI Reasoning <[EMAIL PROTECTED]> wrote:
>
> ...
>
> By the way, how can I get the etc/hosts to update
> automatically whenever the ip address changes? The
> dhcp server is on the same computer as the Xdmcp
> server.
put a line like this in your "/etc/dhcpc/dhcpcd.exe":
# Update the hosts file
/usr/local/bin/fixhostsfile 2>&1 | logger -t "dhcpcd" &
Then put the string "#dhcp dynamic entry" on the line you want to update
in the "/etc/hosts" file.
Then copy this script to the path specified in the line above
("/usr/local/bin"); for this to work you need to have the DOMAINNAME
variable set to your domain in the "/etc/sysconfig/network" file, or
modify the script by hard-coding your domain in the DOMAINNAME variable
of the script:
------------------------%<-------------------------%<------------------------
#!/bin/bash
if [ "$1" = "" ];then
DEVICE="eth0"
else
DEVICE="$1"
fi
IPADDR=`ifconfig $DEVICE| sed -n 's/.*inet addr:
*\(\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*/\1/p'`
[ "$IPADDR" = "" ] && exit 1
echo -n "Fixing hosts file for new dhcp address ... "
HOSTSFILE="/etc/hosts"
HOSTSFILEPERM="0644"
TEMPFILE=`mktemp /tmp/hosts.XXXXXX`
DEFLOCALENTRY="127.0.0.1 localhost.localdomain localhost"
IDSTRING="#dhcp dynamic entry"
HOSTNAME=`hostname|awk -F. '{print $1}'`
DOMAINNAME=`nisdomainname`
#HOSTENTRY="`ypcat hosts|grep ^$IPADDR|uniq` $HOSTNAME.$DOMAINNAME
$HOSTNAME $IDSTRING"
HOSTENTRY="$IPADDR $HOSTNAME.$DOMAINNAME $HOSTNAME $IDSTRING"
if [ -f $HOSTSFILE ]; then
sed "s/.*$IDSTRING.*/$HOSTENTRY/" $HOSTSFILE > $TEMPFILE
mv -f $HOSTSFILE $HOSTSFILE.sv
mv -f $TEMPFILE $HOSTSFILE
else
echo $DEFLOCALENTRY > $HOSTSFILE
echo $HOSTENTRY >> $HOSTSFILE
fi
chmod $HOSTSFILEPERM $HOSTSFILE
echo "done."
------------------------%<---------------------------------------------%<------------------------------------------
good luck ...
--
Eugenio Diaz, BSEE/BSCE
Linux Engineer
[EMAIL PROTECTED]