workaround for dns and hostname issue

This commit is contained in:
Wenkai Yin 2016-11-23 17:29:00 +08:00
parent 2119034c5c
commit 0b3938b411
2 changed files with 30 additions and 3 deletions

View File

@ -10,6 +10,9 @@ function down {
function up {
base_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
$base_dir/start_harbor.sh
echo "Resetting DNS and hostname using vami_ovf_process..."
/opt/vmware/share/vami/vami_ovf_process --setnetwork || true
}
#Configure Harbor

View File

@ -131,20 +131,44 @@ function secure {
cp $ca_cert $ca_download_dir/
}
#Modify hostname
function detectHostname {
#echo "Read attribute using ovfenv: [ vami.domain.Harbor ]"
#hostname=$(ovfenv -k vami.domain.Harbor)
#if [ -n $hostname ]
#then
# echo "Get hostname from ovfenv: $hostname"
# return
#fi
echo "Resetting DNS and hostname using vami_ovf_process..."
/opt/vmware/share/vami/vami_ovf_process --setnetwork || true
hostname=$(hostname --fqdn) || true
if [ -n $hostname ]
then
if [ "$hostname" = "localhost.localdom" ]
then
hostname=""
return
fi
echo "Get hostname from command 'hostname --fqdn': $hostname"
return
fi
}
#Modify hostname
detectHostname
ip_addr=$(ip addr show eth0|grep "inet "|tr -s ' '|cut -d ' ' -f 3|cut -d '/' -f 1)
if [ -z "$hostname" ]
then
echo "Hostname is null, set it to IP"
hostname=$ip_addr
fi
if [ -n "$hostname" ]
then
echo "Read hostname/IP: [ hostname/IP - $hostname ]"
echo "Hostname: $hostname"
configureHarborCfg hostname $hostname
else
echo "Failed to get the hostname/IP"
echo "Failed to get the hostname"
exit 1
fi