From 9b5cad7b619959824e2005d0b3c646e075f58950 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Wed, 4 Oct 2023 12:43:55 -0600 Subject: [PATCH] Behave better when init script is re-run --- gitea/initialize-gitea.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gitea/initialize-gitea.sh b/gitea/initialize-gitea.sh index 5732e93..ae9bfa6 100755 --- a/gitea/initialize-gitea.sh +++ b/gitea/initialize-gitea.sh @@ -43,6 +43,11 @@ token_response=$( curl -s "${GITEA_URL_PREFIX}/api/v1/users/${GITEA_USER}/tokens -u ${GITEA_USER}:${GITEA_PASSWORD} \ -H "Content-Type: application/json") if [[ -n ${token_response} ]] ; then + # Simple check for re-running this script. Ideally we should behave more elegantly. + if [[ "${token_response}" == *"password is invalid"* ]]; then + echo "Note: admin password is invalid, skipping subsqeuent steps" + exit 0 + fi echo ${token_response} | jq --exit-status -r 'to_entries[] | select(.value.name == "'${CERC_GITEA_TOKEN_NAME}'")' if [[ $? == 0 ]] ; then token_found=1