diff options
author | yuryn <Yury.Novitsky@Amdocs.com> | 2017-11-09 20:07:02 +0200 |
---|---|---|
committer | yuryn <Yury.Novitsky@Amdocs.com> | 2018-01-17 23:31:42 +0200 |
commit | d9f6ecd1c5b5296d8bb198b13430d437a6f7a54a (patch) | |
tree | 62e22c5462dd8d26e724d302d72620a755636d56 /kubernetes/portal/resources/scripts/update_hosts.sh | |
parent | 58a0c10a49c79962adfd43d179ad8043c5aa1e81 (diff) |
Refresh /etc/hosts in VNC - reviewed
Change-Id: Ie2c9648e067867d00c035dd9f35560be2ecd6724
Issue-ID: OOM-413
Signed-off-by: yuryn <Yury.Novitsky@Amdocs.com>
Diffstat (limited to 'kubernetes/portal/resources/scripts/update_hosts.sh')
-rw-r--r-- | kubernetes/portal/resources/scripts/update_hosts.sh | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/kubernetes/portal/resources/scripts/update_hosts.sh b/kubernetes/portal/resources/scripts/update_hosts.sh new file mode 100644 index 0000000000..cd38fafb40 --- /dev/null +++ b/kubernetes/portal/resources/scripts/update_hosts.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +_SRC_HOST=$1 +_DST_HOST=$2 +_IP=`getent hosts ${_SRC_HOST}|cut -d' ' -f1` +if [ -z ${_IP} ]; then + echo "Cannot retreive IP for host mapping ${_SRC_HOST} -> ${_DST_HOST}" + exit 1 +fi +_REGEX=".*[[:blank:]]${_DST_HOST}$" +if grep -c -e "${_REGEX}" /etc/hosts > /dev/null 2>&1 ; then + cp /etc/hosts /tmp/hosts + sed -i "s/${_REGEX}/${_IP} ${_DST_HOST}/g" /tmp/hosts + cp /tmp/hosts /etc/hosts +else + echo "${_IP} ${_DST_HOST}" >> /etc/hosts +fi |