Last active
December 1, 2016 20:17
-
-
Save theeye-io/448261981dd174a2314faeb209ce3747 to your computer and use it in GitHub Desktop.
This script enables a node into a pool from an old F5 LoadBalancer's pool.
This file contains hidden or 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/enableNode.exp | |
| expectCommand="ssh theeye@10.2.2.2 \"modify ltm pool \$pool members modify { $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