#!/bin/bash

STORE_FILE=/etc/wifistate
# Pull up the wifi reset pin 
/sbin/insmod "`/usr/bin/dirname $0`/wireless_debug.ko" >/dev/null 2>&1 
if [ $? -ne 0 ]; then
     exit 1 
fi
/bin/echo 1 > /proc/csr_wireless/csr_wifi_rst
/sbin/rmmod wireless_debug

# Insert the wifi driver module
/sbin/modprobe unifi_sdio >/dev/null 2>&1
#/sbin/insmod "`/usr/bin/dirname $0`/unifi_sdio.ko" >/dev/null 2>&1
if [ $? -ne 0 ]; then
     exit 2 
fi

if ! [ -f $STORE_FILE ]
then
	touch $STORE_FILE
fi
echo "1" > $STORE_FILE
