Use crudini to configure

This commit is contained in:
Luke Murphy 2020-03-22 16:42:29 +01:00
parent 7b67d04fa2
commit db4ad413d3
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
2 changed files with 31 additions and 4 deletions

View File

@ -83,6 +83,7 @@
app: gitea
restart: false
config:
DOMAIN: "git.autonomic.zone"
ADMIN_MAIL: "{{ autonomic_admin_mail }}"
ADMIN_PASS: "{{ autonomic_admin_pass }}"
ADMIN_USER: "{{ autonomic_admin_user }}"

View File

@ -6,7 +6,7 @@ setup_db() {
set -eu
if [ -f "/data/gitea/conf/app.ini" ]; then
echo "=====> Running database migration"
echo "-----> Running database migration"
gitea migrate
fi
}
@ -21,21 +21,47 @@ setup_root_user() {
user_count=$(sqlite3 /data/gitea/gitea.db "select count(*) from user;")
if [[ "${user_count}" == "0" ]]; then
echo "=====> Setting up root user for initial deployment"
echo "-----> Setting up root user for initial deployment"
if gitea admin create-user --username "$ADMIN_USER" --password "$ADMIN_PASS" --email "$ADMIN_MAIL" --admin; then
echo "=====> root user added"
echo "-----> root user added"
else
echo "=====> Failed to add root user"
echo "-----> Failed to add root user"
exit 1
fi
fi
}
setup_app_ini() {
set -eu
if [ ! -f "/data/gitea/conf/app.ini" ]; then
return
fi
declare app_ini="/data/gitea/conf/app.ini"
echo "-----> Setting up root user for initial deployment"
crudini --set "$app_ini" database DB_TYPE mysql
crudini --set "$app_ini" database HOST "${DB_HOST}"
crudini --set "$app_ini" database NAME "${DB_NAME}"
crudini --set "$app_ini" database USER "${DB_USER}"
crudini --set "$app_ini" database PASSWD "${DB_PASSWD}"
crudini --set "$app_ini" database SSL_MODE "disable"
crudini --set "$app_ini" server PROTOCOL "http"
crudini --set "$app_ini" server DOMAIN "${DOMAIN}"
crudini --set "$app_ini" server ROOT_URL "https://%(DOMAIN)s/"
crudini --set "$app_ini" sserver HTTP_ADDR ""
crudini --set "$app_ini" sserver HTTP_PORT "3000"
}
main() {
set -eu
setup_db
setup_root_user
setup_app_ini
}
main