RT-IPC_camera/bin/vslocal/cgi-bin/getwifiattr.cgi

76 lines
1.8 KiB
Bash

#!/bin/sh
export PATH=$PATH:/bin/vs/cgi-bin:/bin/vs
IFS=";"
. /bin/vs/cgi-bin/netenv.conf
. /bin/vs/cgi-bin/net_func.sh
. $wifi_config
echo -e "Content-Type:text/plain\r"
echo -e "\r"
wifi_conf_path=/etc/network/wifi.conf
rt_wifiessid=`cat $wifi_conf_path | grep "wifiessid=" | tail -n -1 | awk -F '"' '{ print $2 }'`
rt_findkeytype=`cat $wifi_conf_path | grep "wifikeytype=" | tail -n -1 | awk -F '=' '{ print $2 }'`
rt_wifiwhichkey=`cat $wifi_conf_path | grep "wifiwhichkey=" | tail -n -1 | awk -F '=' '{ print $2 }'`
rt_wifikey=`cat $wifi_conf_path | grep "wifikey=" | tail -n -1 | awk -F '"' '{ print $2 }'`
rt_wifienable=`cat $wifi_conf_path | grep "wifienable=" | tail -n -1 | awk -F '"' '{ print $2 }'`
echo var wifissid = \"${rt_wifiessid}\"\;
echo var wifikeytype = \"${rt_findkeytype}\"\;
echo var wifiwhichkey = \"${rt_wifiwhichkey}\"\;
echo var wifikey=\"${rt_wifikey}\"\;
echo var wifienable=\"${rt_wifienable}\"\;
wifimac=`cat /sys/class/net/${wifidev}/address 2>/dev/null`
echo var wifimac=\"$wifimac\"\;
if [ "$1" == "nolinkstatus" ]
then
exit
fi
wifi_realenable=$(wifi_getenable)
echo var wifienable=\"${wifi_realenable}\"\;
linedstatus=$(net_getlinedstatus)
##有线
if [ $linedstatus = 1 ]
then
echo var linkstatus=\"0\"\;
echo var linkssid=\"\"\;
echo var wifimode=\"\"\;
else
wifistatus_file=/tmpfs/wifistatus.$$
wpa_cli -i $wifidev status >$wifistatus_file 2>/dev/null
. $wifistatus_file
###debug echo wpa_state $wpa_state
linkstatus=$wpa_state
if [ -z ${linkstatus} ]
then
echo var linkstatus=\"0\"\;
elif [ ${linkstatus} = COMPLETED ]
then
echo var linkstatus=\"1\"\;
else
echo var linkstatus=\"0\"\;
fi
echo var linkssid=\"$ssid\"\;
echo var wifimode=\"$(wifi_getmode)\"\;
#rm $wifistatus_file
fi
echo