mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-29 05:35:43 +01:00
parent
977c5a80a0
commit
1dfd130c31
@ -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
|
@ -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
|
||||||
|
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user