#!/bin/sh
#
# Copyright (c) 2000-2014 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
# This file is part of the Emulab network testbed software.
#
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
#
# }}}
#

. /etc/emulab/paths.sh

echo "`date`: ${interface}: ${reason}" >>$LOGDIR/dhclient-exit.log 2>&1

if [ x$reason != xREBOOT -a x$reason != xBOUND -a x$reason != xRENEW -a x$reason != xREBIND ]
then
    exit 0
fi

#
# Remember our server IP, real hostname, router IP, etc.
#
echo $new_domain_name_servers > $BOOTDIR/bossip
echo $new_host_name > $BOOTDIR/realname
echo $new_routers > $BOOTDIR/routerip
echo $new_ip_address > $BOOTDIR/myip
echo $new_subnet_mask > $BOOTDIR/mynetmask
echo $new_domain_name > $BOOTDIR/mydomain
if [ -n "$interface" ]; then
    echo $interface > $BOOTDIR/controlif
fi

#
# See if the Testbed configuration software wants to change the hostname.
#
if [ -x $BINDIR/sethostname.dhclient ]; then
    $BINDIR/sethostname.dhclient >>$LOGDIR/dhclient.log 2>&1
fi

echo "`date`: ${interface}: ${reason}: done" >>$LOGDIR/dhclient-exit.log 2>&1

exit 0
