Last active
December 1, 2016 20:17
-
-
Save theeye-io/8aa8d2b3d458c153e8be4f0cfaefe076 to your computer and use it in GitHub Desktop.
Bash / Expect script for add And enable a node into an old F5 LoadBalancer's pool.
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/bash | |
which expect > /dev/null | |
if [ "$?" -eq "1" ];then echo FAILURE | |
else | |
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ];then echo FAILURE Some var is undefined set PASS $1 POOL $2 ipAndPort $3;exit;fi | |
PASS=$1 | |
POOL=$2 | |
ipAndPort=$3 | |
tempFile=/tmp/resultado | |
#Variable | |
scriptName=/tmp/addNode.exp | |
expectCommand="ssh theeye@10.2.2.2 \"modify ltm pool \$pool members add { $ipAndPort { state up session enabled } }\"" | |
# | |
rm $tempFile | |
cat <<EOF > $scriptName | |
#!/usr/bin/expect -f | |
set password [lindex \$argv 0]; | |
set pool [lindex \$argv 1]; | |
set timeout -1 | |
spawn $expectCommand | |
sleep 1 | |
expect "Password: " | |
send -- "\$password\r" | |
expect eof | |
EOF | |
chmod +x $scriptName | |
state="success" | |
expect $scriptName $PASS $POOL | |
echo $state | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment