From aa49f2d295c57dc57d32cad6dfc29bdda5902d41 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sun, 15 Mar 2020 08:42:50 +0100 Subject: [PATCH] Tweak usage of plugins --- app.json | 6 +----- postdeploy.sh | 20 ++++++++++++++++---- predeploy.sh | 10 +++++----- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/app.json b/app.json index 43fa07d..f6a7c68 100644 --- a/app.json +++ b/app.json @@ -4,11 +4,7 @@ "repository": "https://gitlab.com/autonomic-cooperative/gitea-dokku", "dokku": { "plugins": [ - { "name": "proxy", "commands": ["proxy:ports-add http:80:3000"] }, - { - "name": "letsencrypt", - "commands": ["letsencrypt gitea", "letsencrypt:cron-job --add"] - } + { "name": "proxy", "commands": ["proxy:ports-add http:80:3000"] } ] }, "scripts": { diff --git a/postdeploy.sh b/postdeploy.sh index 78eed12..c716997 100755 --- a/postdeploy.sh +++ b/postdeploy.sh @@ -5,10 +5,14 @@ set -eu -o pipefail setup_root_user() { set -eu + if [ ! -f "/data/gitea/conf/app.ini" ]; then + return + fi + user_count=$(sqlite3 /data/gitea/gitea.db "select count(*) from user;") if [[ "${user_count}" == "0" ]]; then - echo "=====> Setting up root user for first run" + 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" else @@ -18,12 +22,20 @@ setup_root_user() { fi } -main() { +setup_letsencrypt_certs() { set -eu - if [ -f "/data/gitea/conf/app.ini" ]; then - setup_root_user + if [ -d "/home/dokku/gitea/letsencrypt" ]; then + echo "=====> Generating let's encrypt certificates" + dokku letsencrypt gitea fi } +main() { + set -eu + + setup_root_user + setup_letsencrypt_certs +} + main diff --git a/predeploy.sh b/predeploy.sh index 53a26a2..a10cfc4 100755 --- a/predeploy.sh +++ b/predeploy.sh @@ -5,16 +5,16 @@ set -eu -o pipefail setup_db() { set -eu - echo "=====> Running database migration" - gitea migrate + if [ -f "/data/gitea/conf/app.ini" ]; then + echo "=====> Running database migration" + gitea migrate + fi } main() { set -eu - if [ -f "/data/gitea/conf/app.ini" ]; then - setup_db - fi + setup_db } main