HW_DESC=$1
IFACE=$2
test -x /usr/sbin/dhcp6c || exit 0
if [ -r /etc/sysconfig/network/ifcfg-$HW_DESC ] ; then
	. /etc/sysconfig/network/ifcfg-$HW_DESC
fi
case "$DHCP6CLIENT" in
	"")	exit 0;;
	"info")	mode="info";;
	"full") mode="full";;
	*)	exit 0;
esac
if [ -z "$DHCP6C_CONFIG" ]; then
	if [ -r /etc/dhcp6c-${IFACE}.conf ]; then
		DHCP6C_CONFIG=/etc/dhcp6c-${IFACE}.conf
	else
		DHCP6C_CONFIG=/var/lib/dhcpv6/dhcp6c-${IFACE}-${mode}.conf
	fi
fi
if [ ! -e $DHCP6C_CONFIG ]; then
	# create config
	echo "# dhcpv6c config generated by $0" > $DHCP6C_CONFIG
	echo "interface $IFACE {" >> $DHCP6C_CONFIG
	if [ "$mode" = "info" ]; then
		echo "	information-only;" >> $DHCP6C_CONFIG
	else
		echo "  request prefix-delegation;" >> $DHCP6C_CONFIG
	fi
	echo "  request domain-name-servers;" >> $DHCP6C_CONFIG
	echo "	request domain-search-list;" >> $DHCP6C_CONFIG
	echo "};" >> $DHCP6C_CONFIG
fi
startproc /usr/sbin/dhcp6c -c $DHCP6C_CONFIG $IFACE
ps ax |while read pid a b c prog c cfg rest; do
	if [ "$prog" = "/usr/sbin/dhcp6c" -a "$cfg" = "$DHCP6C_CONFIG" ]; then
		echo "$pid" > /var/run/dhcp6c-${IFACE}.pid
	fi
done
