2018-11-15 04:09:57 +01:00
|
|
|
#!/bin/bash
|
2016-04-15 11:23:40 +02:00
|
|
|
|
2019-03-12 12:09:01 +01:00
|
|
|
# If compling source code this dir is harbor's make dir
|
|
|
|
# If install harbor via pacakge, this dir is harbor's root dir
|
|
|
|
harbor_prepare_path="$( cd "$(dirname "$0")" ; pwd -P )"
|
2016-04-15 11:23:40 +02:00
|
|
|
|
2019-03-12 12:09:01 +01:00
|
|
|
echo host make path is set to ${harbor_prepare_path}
|
|
|
|
data_path=$(grep '^[^#]*data_volume:' ${harbor_prepare_path}/harbor.yml | awk '{print $NF}')
|
|
|
|
log_path=$(grep '^[^#]*location:' ${harbor_prepare_path}/harbor.yml | awk '{print $NF}')
|
|
|
|
secretkey_path=$(grep '^[^#]*secretkey_path:' ${harbor_prepare_path}/harbor.yml | awk '{print $NF}')
|
|
|
|
ssl_cert_path=$(grep '^[^#]*ssl_cert:' ${harbor_prepare_path}/harbor.yml | awk '{print $NF}')
|
|
|
|
ssl_cert_key_path=$(grep '^[^#]*ssl_cert_key:' ${harbor_prepare_path}/harbor.yml | awk '{print $NF}')
|
|
|
|
registry_custom_ca_bundle=$(grep '^[^#]*registry_custom_ca_bundle:' ${harbor_prepare_path}/harbor.yml | awk '{print $NF}')
|
2019-03-18 08:07:19 +01:00
|
|
|
|
2019-03-12 12:09:01 +01:00
|
|
|
# Create a input dirs
|
|
|
|
mkdir -p ${harbor_prepare_path}/input
|
|
|
|
input_dir=${harbor_prepare_path}/input
|
|
|
|
mkdir -p $input_dir/nginx
|
|
|
|
mkdir -p $input_dir/keys
|
|
|
|
mkdir -p $input_dir/common
|
2016-02-22 03:00:42 +01:00
|
|
|
|
2019-03-12 12:09:01 +01:00
|
|
|
# Copy nginx config file to input dir
|
|
|
|
cp $ssl_cert_path $input_dir/nginx/server.crt
|
|
|
|
cp $ssl_cert_key_path $input_dir/nginx/server.key
|
|
|
|
|
|
|
|
# Copy secretkey to input dir
|
|
|
|
cp -r $secretkey_path $input_dir/keys
|
|
|
|
|
|
|
|
# Copy ca bundle to input dir
|
|
|
|
if [ -f $registry_custom_ca_bundle ]
|
|
|
|
then
|
|
|
|
cp -r $registry_custom_ca_bundle $input_dir/common/custom-ca-bundle.crt
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Copy harbor.yml to input dir
|
|
|
|
cp ${harbor_prepare_path}/harbor.yml $input_dir/harbor.yml
|
|
|
|
|
2019-03-18 08:07:19 +01:00
|
|
|
# Create secret dir
|
|
|
|
secret_dir=${data_path}/secret
|
|
|
|
config_dir=$harbor_prepare_path/common/config
|
|
|
|
|
|
|
|
# Run prepare script
|
2019-03-12 12:09:01 +01:00
|
|
|
docker run -it --rm -v $input_dir:/input \
|
|
|
|
-v $harbor_prepare_path:/compose_location \
|
|
|
|
-v $config_dir:/config \
|
|
|
|
-v $secret_dir:/secret \
|
|
|
|
-v $log_path:/var/log/harbor \
|
2019-03-18 08:07:19 +01:00
|
|
|
goharbor/prepare:dev $@
|
2019-03-12 12:09:01 +01:00
|
|
|
|
|
|
|
# Clean up input dir
|
|
|
|
rm -rf ${harbor_prepare_path}/input
|