#!/bin/bash while getopts "hwa" optname do case "$optname" in "h") HOST=1 ;; "w") WALL=1 ;; "a") ALL=1 ;; "?") echo "Unrecognized option $OPTARG" exit ;; ":") echo "No argument value for option $OPTARG" exit ;; esac done if [ "$WALL" != "1" -a "$HOST" != "1" -a "$ALL" != "1" ]; then echo "Usage: reboot_wall [-h] [-w] [-a]. One option must be specified." echo -e "\t-h\trun on host" echo -e "\t-w\trun on wall" echo -e "\t-a\trun on host and wall" exit fi if [ "$WALL" == "1" -o "$ALL" == "1" ]; then for i in `cat ~/bin/tiles_list` do echo $i | grep "^#" > /dev/null 2> /dev/null if [ $? != "0" ] then ssh $i reboot fi done fi if [ "$HOST" == "1" -o "$ALL" == "1" ]; then reboot fi