Compare commits

...

3 Commits

Author SHA1 Message Date
pat-s
abf6e2c8a9
create initial secrets before app.ini removal 2023-05-29 20:13:00 +02:00
pat-s
b663ab88a2
condition on existence 2023-05-29 12:07:24 +02:00
pat-s
01b2cd6858
remove existing app.ini before creating it 2023-05-29 11:54:19 +02:00

View File

@ -20,6 +20,28 @@ stringData:
#!/usr/bin/env bash
set -euo pipefail
### initial creation of persistent secrets
if ![ -f ${GITEA_APP_INI} ]; then
function env2ini::generate_initial_secrets() {
# These environment variables will either be
# - overwritten with user defined values,
# - initially used to set up Gitea
# Anyway, they won't harm existing app.ini files
export ENV_TO_INI__SECURITY__INTERNAL_TOKEN=$(gitea generate secret INTERNAL_TOKEN)
export ENV_TO_INI__SECURITY__SECRET_KEY=$(gitea generate secret SECRET_KEY)
export ENV_TO_INI__OAUTH2__JWT_SECRET=$(gitea generate secret JWT_SECRET)
export ENV_TO_INI__SERVER__LFS_JWT_SECRET=$(gitea generate secret LFS_JWT_SECRET)
env2ini::log "...Initial secrets generated\n"
}
fi
# ensure a clean start
if [ -f ${GITEA_APP_INI} ]; then
rm $GITEA_APP_INI
fi
function env2ini::log() {
printf "${1}\n"
}
@ -128,20 +150,6 @@ stringData:
fi
}
function env2ini::generate_initial_secrets() {
# These environment variables will either be
# - overwritten with user defined values,
# - initially used to set up Gitea
# Anyway, they won't harm existing app.ini files
export ENV_TO_INI__SECURITY__INTERNAL_TOKEN=$(gitea generate secret INTERNAL_TOKEN)
export ENV_TO_INI__SECURITY__SECRET_KEY=$(gitea generate secret SECRET_KEY)
export ENV_TO_INI__OAUTH2__JWT_SECRET=$(gitea generate secret JWT_SECRET)
export ENV_TO_INI__SERVER__LFS_JWT_SECRET=$(gitea generate secret LFS_JWT_SECRET)
env2ini::log "...Initial secrets generated\n"
}
env | (grep ENV_TO_INI || [[ $? == 1 ]]) > /tmp/existing-envs
# MUST BE CALLED BEFORE OTHER CONFIGURATION