#!/bin/sh
# Copyright (c) 2004-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-src/rc-scripts/net-scripts/net.modules.d/helpers.d/Attic/dhclient-udhcpc-wrapper,v 1.4.2.2 2005/01/25 10:42:54 uberlord Exp $

# Contributed by Roy Marples (uberlord@gentoo.org)

# Instead of writing new functions for dhclient, we simply map their variables
# over to udhcpc style ones and call those scripts!

iface_type=${1}

echo ${reason}
case "${reason}" in
	BOUND|REBOOT|REBIND) action=bound ;;
	RENEW) action=renew ;;
	RELEASE|PREINIT|FAIL|EXPIRE|TIMEOUT) action=deconfig ;;
	MEDIUM) exit 0 ;;
esac

if [[ -z ${action} ]]; then
	echo "dhclient sent an unknown action ${reason}!" >&2
	exit 1
fi

export ip=${new_ip_address}
export subnet=${new_subnet_mask} 
export broadcast=${new_broadcast_address}
routers=( ${new_routers} )
export router=${routers[0]}
export new_routers=${router}

export hostname=${new_hostname}

export domain=${new_domain_name}
export dns=${new_domain_name_servers}
export new_domain_name=${domain}

export ntpsrv=${new_domain_name_servers}

export nisdomain=${new_nis_domain}
export nissrv=${new_nis_servers}

export module=dhclient

# Execute the dhclient script and exit with it's code
/lib/rcscripts/net.modules.d/helpers.d/udhcpc-${iface_type} ${action}
exit $?
