airship-in-a-bottle/tools/multi_nodes_gate/airship_gate/stages/build-scripts.sh

112 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
set -xe
source "${GATE_UTILS}"
#mkdir -p ${SCRIPT_DEPOT}
#chmod 777 ${SCRIPT_DEPOT}
PROMENADE_TMP_LOCAL="$(basename "$PROMENADE_TMP_LOCAL")"
PROMENADE_TMP="${TEMP_DIR}/${PROMENADE_TMP_LOCAL}"
mkdir -p "$PROMENADE_TMP"
chmod 777 "$PROMENADE_TMP"
DOCKER_RUN_OPTS=("-e" "PROMENADE_DEBUG=${PROMENADE_DEBUG}")
DOCKER_SOCK="/var/run/docker.sock"
sudo chmod o+rw $DOCKER_SOCK
for v in HTTPS_PROXY HTTP_PROXY NO_PROXY https_proxy http_proxy no_proxy
do
if [[ -v "${v}" ]]
then
DOCKER_RUN_OPTS+=("-e" "${v}=${!v}")
fi
done
#CERTS_PATH="/certs/*.yaml"
#KEYS_PATH="/gate/*.yaml"
#if [[ -n "${USE_EXISTING_SECRETS}" ]]
#then
# CERTS_PATH=""
# KEYS_PATH=""
#fi
#log Prepare hyperkube
#docker run --rm -t \
# --network host \
# -v "${PROMENADE_TMP}:/tmp/${PROMENADE_TMP_LOCAL}" \
# "${DOCKER_RUN_OPTS[@]}" \
# "${IMAGE_HYPERKUBE}" \
# cp /hyperkube "/tmp/${PROMENADE_TMP_LOCAL}"
render_pegleg_cli() {
cli_string="pegleg -v site"
if [[ "${GERRIT_SSH_USER}" ]]
then
cli_string+=" -u ${GERRIT_SSH_USER}"
fi
if [[ "${GERRIT_SSH_KEY}" ]]
then
cli_string+=" -k /workspace/${GERRIT_SSH_KEY}"
fi
primary_repo=$(config_pegleg_primary_repo)
if [[ -d "${REPO_ROOT}/${primary_repo}" ]]
then
# NOTE: to get latest pegleg colllect to work
# airship-in-bottle repo has versions (v1.0demo, v1.0dev) within global
# and that is preventing pegleg to collect documents.
# It complains with duplicate data
find "${REPO_ROOT}"/"${primary_repo}" -name "v1.0dev" -type d \
-exec rm -r {} +
cli_string="${cli_string} -r /workspace/${primary_repo}"
else
log "${primary_repo} not a valid primary repository"
return 1
fi
aux_repos=($(config_pegleg_aux_repos))
if [[ ${#aux_repos[@]} -gt 0 ]]
then
for r in ${aux_repos[*]}
do
cli_string="${cli_string} -e ${r}=/workspace/${r}"
done
fi
cli_string="${cli_string} genesis_bundle -b /script/scripts --include-validators"
cli_string="${cli_string} $(config_pegleg_sitename)"
echo "${cli_string}"
}
run_genesis_bundle() {
docker run \
--rm -t \
--network host \
-v "${HOME}/.ssh":/root/.ssh \
-v "${REPO_ROOT}":/workspace \
-v "${TEMP_DIR}":/script \
-v "${PROMENADE_TMP}:/tmp/${PROMENADE_TMP_LOCAL}" \
-e "PROMENADE_TMP=${PROMENADE_TMP}" \
-e "PROMENADE_TMP_LOCAL=/tmp/${PROMENADE_TMP_LOCAL}" \
-e "PROMENADE_ENCRYPTION_KEY=${PROMENADE_ENCRYPTION_KEY}" \
-e "PEGLEG_PASSPHRASE=${PEGLEG_PASSPHRASE}" \
-e "PEGLEG_SALT=${PEGLEG_SALT}" \
-v "${DOCKER_SOCK}:${DOCKER_SOCK}" \
-e "DOCKER_HOST=unix:/${DOCKER_SOCK}" \
"${IMAGE_PEGLEG_CLI}" \
bash -c "$(render_pegleg_cli)"
}
run_genesis_bundle