#!/bin/bash
_OLD_IFS=$IFS
IFS=$'\n'
        
if [ `ifconfig -s | grep '^'$1'\b'` ]
then
	echo 'ENABLED=true'
    ENABLED=true
fi

for line in $(ifconfig $1)
do
        if [ `echo $line|grep 'inet addr:'` ]
        then
                echo 'IP='`echo $line|grep -o 'inet addr:[^ ]*'|cut -d':' -f2`
                echo 'Broadcast='`echo $line|grep -o 'Bcast:[^ ]*'|cut -d':' -f2`
                echo 'SubnetMask='`echo $line|grep -o 'Mask:[^ ]*'|cut -d':' -f2`
        fi
        if [ `echo $line|grep 'MTU:'` ]
        then
                echo 'MTU='`echo $line|grep -o 'MTU:[^ ]*'|cut -d':' -f2`
        fi
        if [ `echo $line|grep 'Metric:'` ]
        then
                echo 'Metric='`echo $line|grep -o 'Metric:[^ ]*'|cut -d':' -f2`
        fi
        if [ `echo $line|grep 'MULTICAST'` ]
        then
                echo 'MULTICAST=true'
                MULTICAST=true
        fi
        if [ `echo $line|grep 'BROADCAST'` ]
        then
                echo 'BROADCAST=true'
                BROADCAST=true
        fi
done
if [ -z $MULTICAST ]
then
	echo 'MULTICAST=false'
fi
if [ -z $BROADCAST ]
then
	echo 'BROADCAST=false'
fi
if [ -z $ENABLED ]
then
	echo 'ENABLED=false'
fi
IFS=$_OLD_IFS