Commit 7919c463 authored by Fangyi Zhou's avatar Fangyi Zhou
Browse files

Merge branch 'gethost-improvement' into 'master'

Gethost improvement

See merge request !23
parents 48acba86 acc7b259
#!/bin/bash
if [ ! -f ./.hosts ]; then
hostsFile='./.hosts'
if [ "$1" == "-f" ]
then
rm -f "$hostsFile"
fi
if [ ! -f "$hostsFile" ]; 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'`)
sta=(0 0 0 0)
......@@ -13,9 +21,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' > "$hostsFile"
fi
hostlist=(`cat ./.hosts`)
hostlist=(`cat "$hostsFile"`)
echo ${hostlist[*]}
......@@ -100,6 +100,7 @@ then
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
then
git pull && echo "Updated successfully"
./gethosts -f >/dev/null
exit $?
fi
fi
......
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