#!/bin/bash
usage="
        Usage: $(basename "$0") [array_id] [-h]
      Example: $(basename "$0")
Functionality: Show the array's status.

      Options:
    -h		Show usage information
"

#if [[ $UID == 0 ]]; then
#	(>&2 echo "DO NOT run with sudo.")
#	echo "$usage"
#	exit 1
#fi

inputArray="all"

if [[ $# == 1 ]]; then
	inputArray=$1
fi

while getopts 'h' OPT; do
    case $OPT in
        h)
            echo "$usage"
			exit 1
    esac
done

scriptDir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )"

echo "----------------------"
echo "Device Status of Wi-Fi NIC array \"$inputArray\":" 
echo "PhyPath DEV PHY [MON] DEV_MacAddr [MON_MacAddr] [CF_Control] [BW] [CF] ProductName"
${scriptDir}/array_eval "$inputArray" "echo PATH DEV PHY MON \$(cat /sys/class/net/DEV/address 2>/dev/null) \$(cat /sys/class/net/MON/address 2>/dev/null) \$(iw MON info | grep -Eo 'channel\\s[0-9]+\\s\\([0-9]+\\sMHz\\)' | grep -Eo '\\([0-9]+' | grep -Eo '[0-9]+') \$(iw MON info | grep -Eo 'width: [0-9]+\\sMHz' | grep -Eo '[0-9]+') \$(iw MON info | grep -Eo 'center[0-9]: [0-9]+\\sMHz' | grep -Eo '\\s[0-9]+' | grep -Eo '[0-9]+') PRODUCTNAME" | sort -k1
echo "----------------------"
