Files
wlan-lanforge-scripts/station-toggle.sh
Ben Greear 72712ff548 Add scripts from the tools directory in the private Candela repo.
These scripts will now be publicly available in a git repo for
easier shared development and change tracking.
2017-10-06 13:41:50 -07:00

47 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
## ##
## Use this script to toggle a set of stations on or off ##
## ##
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
function usage() {
echo "$0 -a up -s staX,staY,staZ..."
echo " to turn stations on"
echo "$0 -a down -s staX,staY,staZ..."
echo " to turn stations off"
}
action=none
stations=""
while getopts ":a:s:" opt ; do
case "${opt}" in
a) action="${OPTARG}";;
s) stations="${OPTARG}";;
*) exit 1;;
esac
done
shift $(( OPTIND - 1 ));
[ -z "$stations" ] && echo "No stations specified." && usage && exit 1
[[ $action = none ]] && echo "No action specified." && usage && exit 1
scriptdir="/home/lanforge/scripts"
portmod="$scriptdir/lf_portmod.pl"
cd $scriptdir
IFS=',' sta_list=($stations)
if [[ $action = up ]] || [[ $action = down ]] ; then
for sta in "${sta_list[@]}"; do
echo "station $sta $action"
$portmod --port_name $sta --set_ifstate $action --quiet 1
done
exit 0
else
echo "What does action $action mean?"
usage
exit 1
fi
#