#!/bin/sh

prereqs() {
	echo ""
}

case $1 in
# get pre-requisites
prereqs)
	prereqs
	exit 0
	;;
esac

ip6address=
ip6dns=
bootif=

for cmdline in $(cat /proc/cmdline); do
	option_name=${cmdline%=*}
	option_value=${cmdline/*=}
	case ${option_name} in
		ip6_address)
			ip6address="$option_value"
			;;
		ip6_dns)
			ip6dns="$option_value"
			;;
		bootif)
			bootif="$option_value"
			;;
		*)
			;;
	esac		
done

if [ -n "$ip6_address" ] && [ -n "$ip6_dns" ] && [ -n "$bootif" ]; then
	# get the right interface
	interface_name="$(ip -o link | sed -ne '/'$bootif'/ { s#^[^:]*: ##; s#:.*$##; p; }')"
	ip link set $interface_name up
	ip -6 addr add $ip6address dev $interface_name
fi
