Last active
December 18, 2015 18:10
-
-
Save kchristensen/fd3dc406cdc21fd5764b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Edit in the commands you want to run | |
COMMAND="uptime" | |
unset CHAR PASS CONFIRM | |
echo -n "Enter webserver root password: " | |
while IFS= read -r -s -n1 CHAR | |
do | |
if [[ -z $CHAR ]]; | |
then | |
break | |
else | |
echo -en "\e[1;36m*\e[0m" | |
PASS+=$CHAR | |
fi | |
done | |
echo | |
echo -en "About to execute \"\e[1;36m$COMMAND\e[0m\" on the webservers, proceed? [y/n]: " | |
read CONFIRM | |
CONFIRM=`echo $CONFIRM|tr [a-z] [A-Z]` | |
if [ "$CONFIRM" == "Y" ]; | |
then | |
for i in `seq -f %02g 2 27` | |
do | |
# There is no web10, only Zuul. | |
if [ $i -eq 10 ]; | |
then | |
continue | |
fi | |
OUTPUT=$(sshpass -p $PASS ssh root@web$i "$COMMAND" 2> /dev/null) | |
if [ $? -eq 5 ]; | |
then | |
echo | |
echo -e "The password you entered is \e[1;31mincorrect\e[0m." | |
echo | |
exit | |
else | |
echo | |
echo -e "Working on \e[1;36mweb$i\e[0m:" | |
echo "$OUTPUT" | |
unset OUTPUT | |
fi | |
done | |
else | |
echo | |
echo -e "\e[1;31mAbort! Abort!\e[0m" | |
exit | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment