-
Notifications
You must be signed in to change notification settings - Fork 19
/
upgradeGerrit.sh
executable file
·50 lines (47 loc) · 1.54 KB
/
upgradeGerrit.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
set -e
GERRIT_WEBURL=${GERRIT_WEBURL:-$1}
LDAP_SERVER=${LDAP_SERVER:-$2}
LDAP_ACCOUNTBASE=${LDAP_ACCOUNTBASE:-$3}
SMTP_SERVER=${SMTP_SERVER:-$4}
USER_EMAIL=${USER_EMAIL:-$5}
SMTP_USER=${SMTP_USER:$6}
SMTP_PASS=${SMTP_PASS:$7}
HTTPD_LISTENURL=${HTTPD_LISTENURL:-http://*:8080}
GERRIT_NAME=${GERRIT_NAME:-gerrit}
GERRIT_VOLUME=${GERRIT_VOLUME:-gerrit-volume}
PG_GERRIT_NAME=${PG_GERRIT_NAME:-pg-gerrit}
GERRIT_IMAGE_NAME=${GERRIT_IMAGE_NAME:-openfrontier/gerrit}
CI_NETWORK=${CI_NETWORK:-ci-network}
# Stop and Delete gerrit container.
if [ -z "$(docker ps -a | grep ${GERRIT_VOLUME})" ]; then
echo "${GERRIT_VOLUME} does not exist."
exit 1
elif [ -z "$(docker ps -a | grep ${PG_GERRIT_NAME})" ]; then
echo "${PG_GERRIT_NAME} does not exist."
exit 1
elif [ -n "$(docker ps | grep ${GERRIT_NAME} | grep -v ${PG_GERRIT_NAME})" ]; then
docker stop ${GERRIT_NAME}
fi
if [ -n "$(docker ps -a | grep ${GERRIT_NAME} | grep -v ${GERRIT_VOLUME} | grep -v ${PG_GERRIT_NAME})" ]; then
docker rm -v ${GERRIT_NAME}
fi
# Start Gerrit.
docker run \
--name ${GERRIT_NAME} \
--net ${CI_NETWORK} \
-p 29418:29418 \
--volumes-from ${GERRIT_VOLUME} \
-e WEBURL=${GERRIT_WEBURL} \
-e HTTPD_LISTENURL=${HTTPD_LISTENURL} \
-e DATABASE_TYPE=postgresql \
-e AUTH_TYPE=LDAP \
-e LDAP_SERVER=${LDAP_SERVER} \
-e LDAP_ACCOUNTBASE=${LDAP_ACCOUNTBASE} \
-e SMTP_SERVER=${SMTP_SERVER} \
-e SMTP_USER=${SMTP_USER} \
-e SMTP_PASS=${SMTP_PASS} \
-e USER_EMAIL=${USER_EMAIL} \
-e GERRIT_INIT_ARGS='--install-plugin=download-commands' \
--restart=unless-stopped \
-d ${GERRIT_IMAGE_NAME}