#!/bin/bash
#
# Copyright (C) 2004 Networks Associates Technology Inc. All Rights Reserved
#
# chkconfig: 2345 12 88 
# description: NIC Speed
#

if [ -f $NETAWSS/.profile.vars ]; then 
    . $NETAWSS/.profile.vars 
else 
    . /var/NAIENV/.profile.vars 
fi 
set -a
PATH=$wsPATH:$PATH
shopt -s extglob
. ${WSMGMT}/shvars-xmlconf

machine_xml=$XMLCONFDIR/machine.xml

set_nic_speeds()
{
    driver=$( /bin/awk '/eth0/{ print $3 }' /etc/modules.conf )
    modopts=$(xsltproc ${WSMGMT}/${driver}.xsl ${machine_xml})
    if [ "${modopts}" != "  " ]
    then
	if [ ! -f /etc/modules.conf.nicspeed ]
        then
	    cp -p /etc/modules.conf /etc/modules.conf.nicspeed
 	fi
        grep -v "^options $driver" /etc/modules.conf.nicspeed > /tmp/nicspeed_$$
        echo options $driver $modopts >> /tmp/nicspeed_$$
        mv /tmp/nicspeed_$$ /etc/modules.conf
	echo alias ip_tables off >> /etc/modules.conf
	echo alias iptable_filter off >> /etc/modules.conf
	/sbin/depmod -a
    fi
}

# Check we have a webshield configuration file and something to do
if [[ ! -f $machine_xml || $1 != @(start|restart|reload) ]]
then
	exit 0
fi

set_nic_speeds

exit 0
