diff --git a/ansible/pre-deploy.yml b/ansible/pre-deploy.yml index 0c1549b..5c6ab25 100644 --- a/ansible/pre-deploy.yml +++ b/ansible/pre-deploy.yml @@ -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 }}" diff --git a/sbin/entrypoint.sh b/sbin/entrypoint.sh index 5c204f9..aacec68 100755 --- a/sbin/entrypoint.sh +++ b/sbin/entrypoint.sh @@ -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