#!/bin/bash source /usr/lib/vserver/dhcp-functions make_resolv_conf(){ local VSERVER=$1 eval `/usr/lib/vserver/printconf.sh --quote $1` if [ -n "$new_domain_name" ] || [ -n "$new_domain_name_servers" ] ; then if [ -f $VSERVERDIR/etc/resolv.conf ] ; then cp -fp $VSERVERDIR/etc/resolv.conf $VSERVERDIR/etc/resolv.conf.predhclient fi local rscf=`mktemp /tmp/XXXXXX` echo '; generated by /usr/lib/vserver/dhclient-script' > $rscf if [ -n "$new_domain_name" ]; then echo search $new_domain_name >> $rscf fi for nameserver in $new_domain_name_servers; do echo nameserver $nameserver >> $rscf done rm -f $VSERVERDIR/etc/resolv.conf cp -f $rscf $VSERVERDIR/etc/resolv.conf chmod 644 $VSERVERDIR/etc/resolv.conf rm -f $rscf fi } make_hosts(){ local VSERVER=$1 eval `/usr/lib/vserver/printconf.sh --quote $1` if [ -f $VSERVERDIR/etc/hosts ] ; then cp -fp $VSERVERDIR/etc/hosts $VSERVERDIR/etc/hosts.predhclient fi local rscf=`mktemp /tmp/XXXXXX` local tag="# inserted by /usr/lib/vserver/dhclient-script" local SHORT_S_HOSTNAME=`echo $S_HOSTNAME | sed s'/\..*//'` echo "$new_ip_address $S_HOSTNAME $SHORT_S_HOSTNAME localhost $tag" > $rscf grep -v "$tag" $VSERVERDIR/etc/hosts.predhclient >> $rscf rm -f $VSERVERDIR/etc/hosts cp -f $rscf $VSERVERDIR/etc/hosts chmod 644 $VSERVERDIR/etc/hosts rm -f $rscf } # echo dhclient: $reason >&2 # env case $reason in BOUND|REBOOT) make_resolv_conf $VSERVER make_hosts $VSERVER _dhcp_create_info_file $interface $VSERVER $PREFIX ;; RENEW|REBIND) if [ "$new_ip_address" != "$old_ip_address" ] ; then logger -t "vserver dhclient-script" "invoked for $reason ('$new_ip_address' != '$old_ip_address') on $interface:$PREFIX-$VSERVER" _dhcp_set_file_variables $interface $VSERVER $PREFIX rm -f $DHCP_INFO_FILE fi ;; EXPIRE|FAIL|TIMEOUT) logger -t "vserver dhclient-script" "invoked for $reason on $interface:$PREFIX-$VSERVER" _dhcp_set_file_variables $interface $VSERVER $PREFIX rm -f $DHCP_INFO_FILE ;; esac