2018-11-15 04:09:57 +01:00
|
|
|
#!/bin/bash
|
2019-04-02 14:08:26 +02:00
|
|
|
set +e
|
2016-04-15 11:23:40 +02:00
|
|
|
|
2019-07-10 08:14:49 +02:00
|
|
|
# If compiling source code this dir is harbor's make dir.
|
|
|
|
# If installing harbor via pacakge, this dir is harbor's root dir.
|
2019-04-30 10:16:06 +02:00
|
|
|
if [[ -n "$HARBOR_BUNDLE_DIR" ]]; then
|
|
|
|
harbor_prepare_path=$HARBOR_BUNDLE_DIR
|
|
|
|
else
|
|
|
|
harbor_prepare_path="$( cd "$(dirname "$0")" ; pwd -P )"
|
|
|
|
fi
|
2019-04-02 14:08:26 +02:00
|
|
|
echo "prepare base dir is set to ${harbor_prepare_path}"
|
2019-03-12 12:09:01 +01:00
|
|
|
data_path=$(grep '^[^#]*data_volume:' ${harbor_prepare_path}/harbor.yml | awk '{print $NF}')
|
2019-03-18 08:07:19 +01:00
|
|
|
|
2019-04-02 14:08:26 +02:00
|
|
|
# If previous secretkeys exist, move it to new location
|
|
|
|
previous_secretkey_path=/data/secretkey
|
|
|
|
previous_defaultalias_path=/data/defaultalias
|
|
|
|
|
|
|
|
if [ -f $previous_secretkey_path ]; then
|
|
|
|
mkdir -p $data_path/secret/keys
|
|
|
|
mv $previous_secretkey_path $data_path/secret/keys
|
|
|
|
fi
|
|
|
|
if [ -f $previous_defaultalias_path ]; then
|
|
|
|
mkdir -p $data_path/secret/keys
|
|
|
|
mv $previous_defaultalias_path $data_path/secret/keys
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Clean up input dir
|
|
|
|
rm -rf ${harbor_prepare_path}/input
|
2019-03-12 12:09:01 +01:00
|
|
|
# Create a input dirs
|
|
|
|
mkdir -p ${harbor_prepare_path}/input
|
|
|
|
input_dir=${harbor_prepare_path}/input
|
2016-02-22 03:00:42 +01:00
|
|
|
|
2019-04-02 14:08:26 +02:00
|
|
|
set -e
|
2019-03-12 12:09:01 +01:00
|
|
|
|
2019-04-02 14:08:26 +02:00
|
|
|
# Copy harbor.yml to input dir
|
|
|
|
if [[ ! "$1" =~ ^\-\- ]] && [ -f "$1" ]
|
2019-03-12 12:09:01 +01:00
|
|
|
then
|
2019-04-02 14:08:26 +02:00
|
|
|
cp $1 $input_dir/harbor.yml
|
|
|
|
else
|
|
|
|
cp ${harbor_prepare_path}/harbor.yml $input_dir/harbor.yml
|
2019-03-12 12:09:01 +01:00
|
|
|
fi
|
|
|
|
|
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-05-09 08:02:44 +02:00
|
|
|
docker run --rm -v $input_dir:/input \
|
2019-03-12 12:09:01 +01:00
|
|
|
-v $harbor_prepare_path:/compose_location \
|
|
|
|
-v $config_dir:/config \
|
|
|
|
-v $secret_dir:/secret \
|
2019-03-18 08:07:19 +01:00
|
|
|
goharbor/prepare:dev $@
|
2019-03-12 12:09:01 +01:00
|
|
|
|
2019-04-02 14:08:26 +02:00
|
|
|
echo "Clean up the input dir"
|
2019-03-12 12:09:01 +01:00
|
|
|
# Clean up input dir
|
2019-04-02 14:08:26 +02:00
|
|
|
rm -rf ${harbor_prepare_path}/input
|