harbor/make/install.sh

119 lines
3.1 KiB
Bash
Raw Normal View History

2016-10-19 08:32:00 +02:00
#!/bin/bash
set -e
DIR="$(cd "$(dirname "$0")" && pwd)"
source $DIR/common.sh
set +o noglob
usage=$'Please set hostname and other necessary attributes in harbor.yml first. DO NOT use localhost or 127.0.0.1 for hostname, because Harbor needs to be accessed by external clients.
Please set --with-notary if needs enable Notary in Harbor, and set ui_url_protocol/ssl_cert/ssl_cert_key in harbor.yml bacause notary must run under https.
Please set --with-trivy if needs enable Trivy in Harbor
Please set --with-chartmuseum if needs enable Chartmuseum in Harbor'
2016-10-19 08:32:00 +02:00
item=0
2017-03-09 12:02:44 +01:00
# notary is not enabled by default
with_notary=$false
# clair is deprecated
with_clair=$false
# trivy is not enabled by default
with_trivy=$false
# chartmuseum is not enabled by default
with_chartmuseum=$false
# flag to using docker compose v1 or v2, default would using v1 docker-compose
DOCKER_COMPOSE=docker-compose
2016-10-19 08:32:00 +02:00
while [ $# -gt 0 ]; do
case $1 in
--help)
note "$usage"
exit 0;;
2017-03-09 12:02:44 +01:00
--with-notary)
2017-06-13 11:13:24 +02:00
with_notary=true;;
--with-clair)
with_clair=true;;
--with-trivy)
with_trivy=true;;
--with-chartmuseum)
with_chartmuseum=true;;
2016-10-19 08:32:00 +02:00
*)
note "$usage"
exit 1;;
esac
shift || true
done
if [ $with_clair ]
then
error "Clair is deprecated please remove it from installation arguments !!!"
exit 1
fi
2016-10-19 08:32:00 +02:00
workdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $workdir
h2 "[Step $item]: checking if docker is installed ..."; let item+=1
2016-10-19 08:32:00 +02:00
check_docker
h2 "[Step $item]: checking docker-compose is installed ..."; let item+=1
check_dockercompose
2016-10-19 08:32:00 +02:00
if [ -f harbor*.tar.gz ]
then
h2 "[Step $item]: loading Harbor images ..."; let item+=1
docker load -i ./harbor*.tar.gz
fi
echo ""
2016-10-19 08:32:00 +02:00
h2 "[Step $item]: preparing environment ..."; let item+=1
if [ -n "$host" ]
then
sed "s/^hostname: .*/hostname: $host/g" -i ./harbor.yml
2016-10-19 08:32:00 +02:00
fi
h2 "[Step $item]: preparing harbor configs ..."; let item+=1
2017-06-13 11:13:24 +02:00
prepare_para=
if [ $with_notary ]
2017-03-09 12:02:44 +01:00
then
prepare_para="${prepare_para} --with-notary"
2017-03-09 12:02:44 +01:00
fi
if [ $with_trivy ]
then
prepare_para="${prepare_para} --with-trivy"
fi
if [ $with_chartmuseum ]
then
prepare_para="${prepare_para} --with-chartmuseum"
fi
2017-06-13 11:13:24 +02:00
./prepare $prepare_para
2016-10-19 08:32:00 +02:00
echo ""
if [ -n "$DOCKER_COMPOSE ps -q" ]
then
note "stopping existing Harbor instance ..."
$DOCKER_COMPOSE down -v
2016-10-19 08:32:00 +02:00
fi
echo ""
h2 "[Step $item]: starting Harbor ..."
if [ $with_chartmuseum ]
then
warn "
Chartmusuem will be deprecated as of Harbor v2.6.0 and start to be removed in v2.8.0 or later.
Please see discussion here for more details. https://github.com/goharbor/harbor/discussions/15057"
fi
if [ $with_notary ]
then
warn "
Notary will be deprecated as of Harbor v2.6.0 and start to be removed in v2.8.0 or later.
You can use cosign for signature instead since Harbor v2.5.0.
Please see discussion here for more details. https://github.com/goharbor/harbor/discussions/16612"
fi
$DOCKER_COMPOSE up -d
2016-10-19 08:32:00 +02:00
success $"----Harbor has been installed and started successfully.----"