#!/bin/bash
usage="
        Usage: $(basename "$0") [array_id] [-h]
      Example: $(basename "$0")
Functionality: Restore the ordinary Wi-Fi connectivities for the input array.
               If <array_id> is empty, restore for all NICs.

      Options:
    array_id  The array to be restored.
    -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 )"

${scriptDir}/Stop_Monitor_Interface $inputArray
${scriptDir}/DisconnectAP $inputArray
${scriptDir}/array_eval $inputArray nmcli device set DEV managed yes
if [ -f "${scriptDir}/beta/RestoreAth9kBandwidth" ]; then
    ${scriptDir}/beta/RestoreAth9kBandwidth $inputArray
else
    echo "-----------------------------------------------------------------------------------"
    echo "If you have changed baseband bandwidth, you may need to reboot system to reset."
    echo "-----------------------------------------------------------------------------------"
fi

