mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-24 01:27:49 +01:00
134 lines
3.3 KiB
Bash
Executable File
134 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# Requires: openssl
|
|
|
|
source ./harbor.cfg
|
|
|
|
config_path="./config"
|
|
ui_path="./config/ui"
|
|
db_path="./config/db"
|
|
tpl_path="./templates"
|
|
|
|
mkdir -p $tpl_path
|
|
mkdir -p $ui_path $db_path
|
|
|
|
declare -a arr=("$ui_path/env" "$ui_path/app.conf" "$config_path/registry/config.yml" "$db_path/env")
|
|
|
|
for i in "${arr[@]}"; do
|
|
if [ -e $i ]; then
|
|
echo "Clearing the configuration file: "$i
|
|
rm $i
|
|
fi
|
|
done
|
|
|
|
echo "appname = registry
|
|
runmode = dev
|
|
|
|
[lang]
|
|
types = en-US|zh-CN
|
|
names = en-US|zh-CN
|
|
|
|
[dev]
|
|
httpport = 80
|
|
|
|
[mail]
|
|
host = $email_server
|
|
port = $email_server_port
|
|
username = $email_username
|
|
password = $email_password
|
|
from = $email_from" > $ui_path/app.conf
|
|
echo "Generated configuration file: "$ui_path/app.conf
|
|
|
|
echo "MYSQL_HOST=mysql
|
|
MYSQL_PORT=3306
|
|
MYSQL_USR=root
|
|
MYSQL_PWD=$db_password
|
|
REGISTRY_URL=http://registry:5000
|
|
CONFIG_PATH=/etc/ui/app.conf
|
|
HARBOR_REG_URL=$hostname
|
|
HARBOR_ADMIN_PASSWORD=$harbor_admin_password
|
|
HARBOR_URL=$hostname
|
|
AUTH_MODE=$auth_mode
|
|
LDAP_URL=$ldap_url
|
|
LDAP_BASE_DN=$ldap_basedn
|
|
SELF_REGISTRATION=$self_registration
|
|
LOG_LEVEL=debug" > $ui_path/env
|
|
echo "Generated configuration file: "$ui_path/env
|
|
|
|
echo "MYSQL_ROOT_PASSWORD=$db_password" > $config_path/db/env
|
|
echo "Generated configuration file: "$config_path/db/env
|
|
|
|
echo "version: 0.1
|
|
log:
|
|
level: debug
|
|
fields:
|
|
service: registry
|
|
storage:
|
|
cache:
|
|
layerinfo: inmemory
|
|
filesystem:
|
|
rootdirectory: /storage
|
|
maintenance:
|
|
uploadpurging:
|
|
enabled: false
|
|
delete:
|
|
enabled: true
|
|
http:
|
|
addr: :5000
|
|
secret: placeholder
|
|
debug:
|
|
addr: localhost:5001
|
|
auth:
|
|
token:
|
|
issuer: registry-token-issuer
|
|
realm: $ui_url/service/token
|
|
rootcertbundle: /etc/registry/root.crt
|
|
service: token-service
|
|
|
|
notifications:
|
|
endpoints:
|
|
- name: harbor
|
|
disabled: false
|
|
url: http://ui/service/notifications
|
|
timeout: 500
|
|
threshold: 5
|
|
backoff: 1000" > $config_path/registry/config.yml
|
|
echo "Generated configuration file: "$config_path/registry/config.yml
|
|
|
|
is_fail=0
|
|
|
|
if [ $customize_token == "on" ];then
|
|
|
|
if [ -e $ui_path/private_key.pem ]; then
|
|
echo "clearing the origin private_key.pem in "$ui_pth
|
|
rm $ui_path/private_key.pem
|
|
fi
|
|
openssl genrsa -out $ui_path/private_key.pem 4096
|
|
if [ -e $ui_path/private_key.pem ]; then
|
|
echo "private_key.gem has been generated in "$ui_path
|
|
else echo "generate private_key.gem fail."
|
|
is_fail=1
|
|
fi
|
|
|
|
if [ -e $config_path/registry/root.crt ]; then
|
|
echo "clearing the origin root.crt in "$config_path"/registry"
|
|
rm $config_path/registry/root.crt
|
|
fi
|
|
|
|
openssl req -new -x509 -key $ui_path/private_key.pem -out $config_path/registry/root.crt -days 3650 \
|
|
-subj "/C=$crt_countryname/ST=$crt_state/L=$crt_name/O=$crt_organizationname/OU=$crt_organizationalunitname"
|
|
if [ -e $config_path/registry/root.crt ]; then
|
|
echo "root.crt has been generated in "$config_path"/registry"
|
|
else echo "generate root.crt fail."
|
|
is_fail=1
|
|
fi
|
|
elif [ $customize_token != "off" ]; then
|
|
echo "wrong args found in customize_token: "$customize_token
|
|
is_fail=1
|
|
fi
|
|
|
|
if [ $is_fail -eq 0 ];then
|
|
echo "The configuration files are ready, please use docker-compose to start the service."
|
|
else
|
|
echo "some problem occurs."
|
|
fi
|