#!/bin/sh loggerName=wpa_action.sh IFNAME=$1 CMD=$2 WPA_CLI=/opt/ti-wireless/WL6.1.6.0.3/wpa_cli WLAN_CONFIG=/home/tool/config/wlan.json DHCP_CLIENT=/etc/udhcpc/./startdhcpclient.sh RENEWDHCP=/etc/udhcpc/./renewdhcplease.sh case "$2" in CONNECTED) cat $WLAN_CONFIG | grep 'dhcp' > /dev/null 2>&1 if [ "$?" -eq "0" ]; then ps | grep "[u]dhcpc -i tiwlan0" | awk '{print $1}' if [ "$?" -eq "0" ]; then $DHCP_CLIENT & else PID=`ps | grep "[u]dhcpc -i tiwlan0" | awk '{print $1}'` logger -s -t $loggerName "dhcp client already activ pid<$PID>"; $RENEWDHCP & fi else cat $WLAN_CONFIG | grep '"garp": true' > /dev/null 2>&1 if [ "$?" -eq "0" ]; then ifconfig $IFNAME down ifconfig $IFNAME up fi fi SSID=`$WPA_CLI -i$IFNAME status | grep ^ssid= | cut -f2- -d=` logger -s -t $loggerName "WPA supplicant: connection established with $SSID"; ;; DISCONNECTED) logger -s -t $loggerName "WPA supplicant: connection lost"; ;; esac