Verified Commit 840b6d47 authored by Fangyi Zhou's avatar Fangyi Zhou
Browse files

Improve gethosts

- Remove some hosts not belonging to lab
parent a3601272
#!/bin/bash
if [ "$1" == "-f" ]
then
rm -f ./hosts
fi
if [ ! -f ./.hosts ]; then
origin=(`ifconfig -a eno1 | grep "inet addr" | sed -e 's/:/ /g' | awk '{print $3}' | sed -e 's/\./ /g'`)
snmask=(`ifconfig -a eno1 | grep "inet addr" | sed -e 's/:/ /g' | awk '{print $7}' | sed -e 's/\./ /g'`)
......@@ -13,9 +19,13 @@ if [ ! -f ./.hosts ]; then
hostlist=()
for ip in ${iplist[*]}
do
hostlist+=(`host $ip | awk '/pointer/ { print $5 }' | sed -e 's/\./ /g' | awk '{print $1}'`)
hostname=(`host $ip | awk '/pointer/ { print $5 }' | sed -e 's/\./ /g' | awk '{print $1}'`)
if [[ "$hostname" =~ ^[a-z]+[0-9]{2}$ ]]
then
hostlist+="$hostname "
fi
done
echo ${hostlist[*]} | sed -E 's/([^ ]*vm[^ ]* )|((cider|lexis)[0-9]{2} )//g' > ./.hosts
echo ${hostlist[*]} | sed -E 's/(cider|lexis)[0-9]{2}//g' > ./.hosts
fi
hostlist=(`cat ./.hosts`)
echo ${hostlist[*]}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment