#!/bin/bash

if [ -z "$IFACE" ] ; then
    exit 1
fi

if [ -z "$IF_ADD_IPS" ] ; then
    exit 0
fi

shopt -s extglob

echo "Adding IPs: $IF_ADD_IPS..."
for ip in $IF_ADD_IPS ; do
    ip_spec=${IF_ADD_IPS#*=}
    if [ "$ip_spec" != "$IF_ADD_IPS" ] ; then
	name_spec=${IF_ADD_IPS%%=*}
	ip addr add $ip_spec broadcast + label $IFACE:$name_spec dev $IFACE
    else
	ip addr add $ip broadcast + dev $IFACE
    fi
done
					
# This is for purpose - to discard the status of ip add for an address, which already exists on the device
exit 0
