#!/bin/bash # Parse command line options using getopt options=$(getopt -o f:l:o:ah --long first:,last:,only:,all,help -- "$@") eval set -- "$options" LIST="" # define nodes (names/MACs/IPs) source ./node_list.sh source ./node_addresses.sh ALLNODES=${neighbors["all"]} # Function to display usage information function display_usage { echo "Usage: $0 [--first <[0..84]>] [--last <[0..84]>] [--all ] [--only <[0..84]>] [--help]" } # Function to display help information function display_help { display_usage echo echo "Options:" echo " --first (-f) Set the start node (0)" echo " --last (-l) Set the stop node (24)" echo " --only (-o) Only one node" echo " --all (-a) Set all nodes" echo " --help (-h) Displays help" } # argument parsing while true; do case "$1" in -f|--first) start_node="$2" shift 2 ;; -l|--last) stop_node="$2" shift 2 ;; -o|--only) start_node="$2" stop_node="$2" shift 2 ;; -a|--all) start_node=0 stop_node=84 all=true shift ;; -h|--help) display_help exit 0 ;; --) shift break ;; *) display_usage exit 1 ;; esac done # arranging node list LIST=$(seq $start_node 1 $stop_node) # check ranges if [[ $start_node -gt 84 || $start_node -lt 0 || $stop_node -gt 84 || $stop_node -lt 0 ]];then echo "Nodes out of range" echo "" display_help exit 1 fi # interate list for i in $LIST ; do found=false # search for node in defined node list (array) for j in "${NODES[@]}"; do for k in $j; do #echo $j if [[ $i -eq $k ]]; then found=true fi done done if [[ $i -lt 10 ]];then current=0$i else current=$i fi if [ "$found" = true ]; then # get node ip ssh root@apu$current "iw dev mesh0 station dump" | grep Station | awk '{print $2}' #ssh -o StrictHostKeyChecking=no "$login"@"apu$current" "sudo reboot" & else # only inform the user about missing node defines when defining ranges by him-/herself if [ "$all" = false ]; then echo "Node apu$current not defined" fi fi done MAC_ADDRESSES=$(ssh user@$REMOTE_IP "iw dev mesh0 station dump" | grep Station | awk '{print $2}') # TODO: put MAC addresses into a -A Array... and print them