#!/bin/sh

. /etc/init.d/functions

cd /etc/sysconfig/network-scripts
. ./network-functions

[ -f ../network ] && . ../network

CONFIG=${1}

[ -z "${CONFIG}" ] && {
    echo $"Usage: ${0} <device name>" >&2
    exit 1
}

need_config ${CONFIG}

source_config

# Work around https://bugzilla.redhat.com/show_bug.cgi?id=683947
if [ "${NETWORKING_IPV6}" = "yes" ]; then
    if [[ "${DHCPV6C}"  = [Yy1]* ]] && [ -x /sbin/dhcp6c ]; then
        # Grep expects there to be some options... Hack around no options being set
	GREP_EXPECT="dhcp6c ${DHCPV6C_OPTIONS} ${DEVICE}"
        [ -z "${DHCPV6C_OPTIONS}" ] && GREP_EXPECT="dhcp6c ${DEVICE}"
        /sbin/dhcp6c ${DHCPV6C_OPTIONS} ${DEVICE}
        dhcp6_pid=(`/bin/ps -eo 'pid,args' | /bin/grep "${GREP_EXPECT}" | egrep -v grep`)
        [ -n  "$dhcp6_pid" ] && echo ${dhcp6_pid[0]} > /var/run/dhcp6c_${DEVICE}.pid
    fi;
fi
