#!/bin/sh

RT3070_DRIVER=/lib/modules/sylinux/char/rt3070sta.ko

RT3070_EXIST=`/usr/bin/lsusb | grep :3070`
INSTALLED_WLAN_FILE=/var/log/installed_wlan
WLAN_IFNAME=/var/log/wlan_ifname

if [ -z "$RT3070_EXIST" ]; then
	RT3070_EXIST=`/usr/bin/lsusb | grep :7711`
fi

if [ -n "$RT3070_EXIST" ]; then
	insmod $RT3070_DRIVER
	echo "RT3070" > $INSTALLED_WLAN_FILE
	# ra0 up&down make to get WLAN MAC address
	/sbin/ifconfig ra0 up
	/sbin/ifconfig ra0 down
else
	# check gwdev is ra0 when no wlan-if
	. /etc/sysconfig/network
	if [ "$GATEWAYDEV" == "ra0" ]; then
		/bin/sed -i 's/ra0/eth0/g' /etc/sysconfig/network
	fi
fi

echo "ra0" > $WLAN_IFNAME

exit 0
