#!/bin/sh
IPADDR="192.168.33.5"
SSID=test5G
PASS=test5G

DEVNAME="$1"
COMMAND="$2"

case $COMMAND in
    'start')
        echo "country=JP" > /Net/wpa_supplicant-wlan.conf
        echo "ap_scan=1" >> /Net/wpa_supplicant-wlan.conf
        echo "fast_reauth=1" >> /Net/wpa_supplicant-wlan.conf
        wpa_passphrase $SSID $PASS >> /Net/wpa_supplicant-wlan.conf
        wpa_supplicant -i $DEVNAME -D wext -c /Net/wpa_supplicant-wlan.conf -P /tmp/wpa-pid -B
        
        # static 
        #ifconfig $DEVNAME $IPADDR up
        
        # dhcp
        #ifconfig $DEVNAME up
        dhcpcd -t 180 $DEVNAME
    ;;
    
    'stop')
        # static 
        #ifconfig $DEVNAME down
        
        # dhcp
        dhcpcd -k -d $DEVNAME
        ifconfig $DEVNAME down
        kill `cat /tmp/wpa-pid`
    ;;
    
    *)
        exit 1
    ;;

esac
exit 0

# EOF #
