mhassan2 / splunk-n-box

Docker Splunk "Orchestration" bash script (6,000+ lines) to create fully automated pre-configured splunk site-2-site clusters or stand alone containers. Awesome tool for training and testing!
https://github.com/mhassan2/splunk-n-box
138 stars 32 forks source link

last_ip_used does not sort correctly #10

Open csiess opened 6 years ago

csiess commented 6 years ago

Hi,

thanks a lot for this great script. I had a small issue:

START_ALIAS_LINUX="10.2.237.1"; END_ALIAS_LINUX="10.2.237.49"

This stopped the script working beyond IP 10.2.237.10 because: last_ip_used outputs 10.2.237.9 where it should output 10.2.237.10:

docker inspect --format '{{ .HostConfig }}' $(docker ps -aq)| grep -o '[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+ 8000'|cut -d" " -f 1|sort -u|tail -1 10.2.237.9

docker inspect --format '{{ .HostConfig }}' $(docker ps -aq)| grep -o '[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+ 8000'|cut -d" " -f 1|sort -u 10.2.237.10 10.2.237.2 10.2.237.3 10.2.237.4 10.2.237.5 10.2.237.6 10.2.237.7 10.2.237.8 10.2.237.9

Adding the -n switch to the sort command fixes this:

docker inspect --format '{{ .HostConfig }}' $(docker ps -aq)| grep -o '[0-9]+[.][0-9]+[.][0-9]+[.][0-9]+ 8000'|cut -d" " -f 1|sort -un|tail -1 10.2.237.10