#!/bin/sh

############
# CHANGELOG
#===========
# 2010/11/18    crms00273276    Claire Dechriste
#
################

. /etc/init.d/rc.config
settingsfile=wpa8021x.cfg

. $NVDEFAULT_ROOT/$settingsfile
[[ -f $NVLOCAL_ROOT/$settingsfile ]] && . $NVLOCAL_ROOT/$settingsfile
[[ -f $NVDM_ROOT/$settingsfile ]] && . $NVDM_ROOT/$settingsfile


Usage()
{
	echo "802.1X configuration : Get the 802.1x parameters";
	echo "Usage:"
	echo " 		dot1x"
}

list()
{
	if [ "$WPA8021XCFG_MODE" == "MD5" ] 
        then 
		echo "MD5:ENABLED"
                echo "TLS:DISABLED"
        elif [ "$WPA8021XCFG_MODE" == "TLS" ]
	then		
                echo "MD5:DISABLED"
		echo "TLS:ENABLED"
        elif [ "$WPA8021XCFG_MODE" == "MD5_TLS" ]
	then		
                echo "MD5:ENABLED"
		echo "TLS:ENABLED"

	else
        	echo "MD5:DISABLED"
		echo "TLS:DISABLED"
	fi
 
	echo "Login: $WPA8021XCFG_LOGIN"
        echo "MAC Use: $WPA8021XCFG_MAC2LOGIN"
        if [ -s /config/local/secdat ] ; then
            echo "MD5 passwd: ******"
        else
            echo "MD5 passwd: <empty>"
        fi
        echo "TLS Server Authent: $WPA8021XCFG_SERVER_AUTHENT"
}

exit_ko()
{
	echo "dot1x KO"
	exit 1
}


exit_ok()
{
	echo "dot1x OK"
	exit 0
}

[ -x $cli ] || { echo "Cannot run $cli"; exit_ko;}
[ $# -ne 0 ] || {  list ; exit_ok;}

if [ $# -eq 0 ]
then
	exit_ok
else
	Usage
	exit_ko
fi 


