mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-16 15:25:18 +01:00
b15c6bcdc7
fix typos in prepare script
59 lines
1.7 KiB
Bash
Executable File
59 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
set +e
|
|
|
|
# If compiling source code this dir is harbor's make dir.
|
|
# If installing harbor via pacakge, this dir is harbor's root dir.
|
|
if [[ -n "$HARBOR_BUNDLE_DIR" ]]; then
|
|
harbor_prepare_path=$HARBOR_BUNDLE_DIR
|
|
else
|
|
harbor_prepare_path="$( cd "$(dirname "$0")" ; pwd -P )"
|
|
fi
|
|
echo "prepare base dir is set to ${harbor_prepare_path}"
|
|
data_path=$(grep '^[^#]*data_volume:' ${harbor_prepare_path}/harbor.yml | awk '{print $NF}')
|
|
|
|
# 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
|
|
# Create a input dirs
|
|
mkdir -p ${harbor_prepare_path}/input
|
|
input_dir=${harbor_prepare_path}/input
|
|
|
|
set -e
|
|
|
|
# Copy harbor.yml to input dir
|
|
if [[ ! "$1" =~ ^\-\- ]] && [ -f "$1" ]
|
|
then
|
|
cp $1 $input_dir/harbor.yml
|
|
else
|
|
cp ${harbor_prepare_path}/harbor.yml $input_dir/harbor.yml
|
|
fi
|
|
|
|
# Create secret dir
|
|
secret_dir=${data_path}/secret
|
|
config_dir=$harbor_prepare_path/common/config
|
|
|
|
# Run prepare script
|
|
docker run --rm -v $input_dir:/input:z \
|
|
-v $data_path:/data:z \
|
|
-v $harbor_prepare_path:/compose_location:z \
|
|
-v $config_dir:/config:z \
|
|
-v $secret_dir:/secret:z \
|
|
-v /:/hostfs:z \
|
|
goharbor/prepare:dev $@
|
|
|
|
echo "Clean up the input dir"
|
|
# Clean up input dir
|
|
rm -rf ${harbor_prepare_path}/input
|