--- Eugenio Diaz <[EMAIL PROTECTED]> wrote:
> --- 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."
>
>
------------------------%<---------------------------------------------%<------------------------------------------
This did not work for me.
in /etc/hosts I put
----------------
#dhcp dynamic entry marygrace
192.168.1.3 jillestial.home.network jillestial
192.168.1.6 siway.home.network siway
#dhcp dynamic entry sidell
---------------------
at the bottom of dhcpcd.exe I put
------------------
# ==== Put your code for the case interface has been
shut down here
# ==== End
;;
esac
# Update the hosts file
/usr/local/bin/fixhostsfile 2>&1 | logger -t "dhcpcd"
&
exit 0
--------------------
I copied /usr/local/bin/fixhostsfile and made chmod
755 with my domain name hard coded in
------------------
IDSTRING="#dhcp dynamic entry"
HOSTNAME=`hostname|awk -F. '{print $1}'`
DOMAINNAME=`home.network`
#HOSTENTRY="`ypcat hosts|grep ^$IPADDR|uniq`
$HOSTNAME.$DOMAINNAME
---------------------
These are the relevent excerpts, of course.
Anyway, I still cannot ping these two accounts.
=====
SI Reasoning
[EMAIL PROTECTED]
A requirement of creativity is that it contributes to change. Creativity keeps
the creator alive.
-FRANK HERBERT, unpublished notes
__________________________________________________
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/