Merge pull request #1058 from ywk253100/161110_hostname

Fixes #995, fixes #1047
This commit is contained in:
Daniel Jiang 2016-11-12 18:02:13 +08:00 committed by GitHub
commit 74714fe74a
3 changed files with 23 additions and 10 deletions

View File

@ -3,7 +3,6 @@ set -e
attrs=( attrs=(
harbor_admin_password harbor_admin_password
auth_mode
ldap_url ldap_url
ldap_searchdn ldap_searchdn
ldap_search_pwd ldap_search_pwd
@ -37,13 +36,18 @@ function format {
} }
#Modify hostname #Modify hostname
ip=$(ip addr show eth0|grep "inet "|tr -s ' '|cut -d ' ' -f 3|cut -d '/' -f 1) hostname=$(hostname --fqdn) || true
if [ -n "$ip" ] if [ -z "$hostname" ]
then then
echo "Read IP address: [ IP - $ip ]" hostname=$(ip addr show eth0|grep "inet "|tr -s ' '|cut -d ' ' -f 3|cut -d '/' -f 1)
sed -i -r s/"hostname = .*"/"hostname = $ip"/ $cfg fi
if [ -n "$hostname" ]
then
echo "Read hostname/IP: [ hostname/IP - $hostname ]"
sed -i -r s/"hostname\s*=\s*.*"/"hostname = $hostname"/ $cfg
else else
echo "Failed to get the IP address" echo "Failed to get the hostname/IP"
exit 1 exit 1
fi fi
@ -57,7 +61,7 @@ if [ -n "$ssl_cert" ] && [ -n "$ssl_cert_key" ]
then then
echo "ssl_cert and ssl_cert_key are set, using HTTPS protocol" echo "ssl_cert and ssl_cert_key are set, using HTTPS protocol"
protocol=https protocol=https
sed -i -r s%"#?ui_url_protocol = .*"%"ui_url_protocol = $protocol"% $cfg sed -i -r s%"#?ui_url_protocol\s*=\s*.*"%"ui_url_protocol = $protocol"% $cfg
echo $ssl_cert > /data/server.crt echo $ssl_cert > /data/server.crt
format /data/server.crt format /data/server.crt
echo $ssl_cert_key > /data/server.key echo $ssl_cert_key > /data/server.key
@ -83,6 +87,6 @@ do
bs=$(echo $value | base64) bs=$(echo $value | base64)
#value={base64}$bs #value={base64}$bs
fi fi
sed -i -r s%"#?$attr = .*"%"$attr = $value"% $cfg sed -i -r s%"#?$attr\s*=\s*.*"%"$attr = $value"% $cfg
fi fi
done done

View File

@ -34,9 +34,18 @@ tar -zxvf $base_dir/../harbor-offline-installer*.tgz -C $base_dir/../
echo "Loading images..." echo "Loading images..."
load load
#Configure Harbor
echo "Configuring Harbor..." echo "Configuring Harbor..."
chmod 600 $base_dir/../harbor/harbor.cfg chmod 600 $base_dir/../harbor/harbor.cfg
#Configure authentication mode
echo "Read attribute using ovfenv: [ auth_mode ]"
auth_mode=$(ovfenv -k auth_mode)
if [ -n "$auth_mode" ]
then
sed -i -r s%"#?auth_mode\s*=\s*.*"%"auth_mode = $auth_mode"% $base_dir/../harbor/harbor.cfg
fi
#Configure other attrs
configure configure
#Start Harbor #Start Harbor

View File

@ -15,7 +15,7 @@ addIptableRules
#Stop Harbor #Stop Harbor
echo "Shutting down Harbor..." echo "Shutting down Harbor..."
down down || true
#Garbage collection #Garbage collection
value=$(ovfenv -k gc_enabled) value=$(ovfenv -k gc_enabled)