Initial commit
Add default gerrit projects config for sandbox

Related-PROD: RE-336

Change-Id: I788bb9317005b8094bfbcde75da77a993e0404cb
diff --git a/tests/update b/tests/update
new file mode 100755
index 0000000..1de585b
--- /dev/null
+++ b/tests/update
@@ -0,0 +1,38 @@
+#!/bin/bash -ex
+: ${JEEPYB_WORKSPACE:=$(pwd)/.workspace}
+
+PROJECTS_INI=${JEEPYB_WORKSPACE}/projects.ini
+PROJECTS_YAML=$(pwd)/projects.yaml
+
+export PROJECTS_INI PROJECTS_YAML
+
+mkdir -p "${JEEPYB_WORKSPACE}"
+
+cp "$(pwd)/conf/projects.ini.template" "${PROJECTS_INI}"
+
+[ -n "${JEEPYB_GERRIT_HOST}" ] \
+    && sed -i "s|^gerrit-host.*|gerrit-host=${JEEPYB_GERRIT_HOST}|" "${PROJECTS_INI}"
+[ -n "${JEEPYB_USER}" ] \
+    && sed -i "s|^gerrit-user.*|gerrit-user=${JEEPYB_USER}|" "${PROJECTS_INI}"
+[ -n "${JEEPYB_COMMITTER}" ] \
+    && sed -i "s|^gerrit-committer.*|gerrit-committer=${JEEPYB_COMMITTER}|" "${PROJECTS_INI}"
+[ -n "${JEEPYB_SSH_KEY}" ] \
+    && echo "gerrit-key=${JEEPYB_SSH_KEY}" >> "${PROJECTS_INI}"
+
+COMMITTER=$(git config --file "${PROJECTS_INI}" projects.gerrit-committer)
+GIT_COMMITTER_NAME=$(echo "${COMMITTER}" | awk -F '[<>]' '{print $1}')
+GIT_COMMITTER_NAME=${GIT_COMMITTER_NAME% *}
+GIT_COMMITTER_EMAIL=$(echo "${COMMITTER}" | awk -F '[<>]' '{print $2}')
+export GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL
+
+sed -i "s|^gerrit-system-user.*|gerrit-system-user=$(id -u)|" "${PROJECTS_INI}"
+sed -i "s|^gerrit-system-group.*|gerrit-system-group=$(id -u)|" "${PROJECTS_INI}"
+sed -i "s|^acl-dir.*|acl-dir=$(pwd)/acls|" "${PROJECTS_INI}"
+sed -i "s|^local-git-dir.*|local-git-dir=${JEEPYB_WORKSPACE}/git|" "${PROJECTS_INI}"
+sed -i "s|^jeepyb-cache-dir.*|jeepyb-cache-dir=${JEEPYB_WORKSPACE}/cache|" "${PROJECTS_INI}"
+
+# Backward compatibility with legacy format:
+# remove acls/ path prefix from `acl-config` params
+sed -i 's|acl-config: acls/|acl-config: |g' "${PROJECTS_YAML}"
+
+manage-projects -v -d $@