From 1d246750091a30078f87c55db0a300de504cdf48 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sun, 15 Mar 2020 09:05:13 +0100 Subject: [PATCH] Only do predeploy --- app.json | 3 +-- postdeploy.sh | 41 ----------------------------------------- predeploy.sh | 31 +++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 43 deletions(-) delete mode 100755 postdeploy.sh diff --git a/app.json b/app.json index 75db67e..0a6005e 100644 --- a/app.json +++ b/app.json @@ -12,8 +12,7 @@ }, "scripts": { "dokku": { - "predeploy": "bash /app/predeploy.sh", - "postdeploy": "bash /app/postdeploy.sh" + "predeploy": "bash /app/predeploy.sh" } }, "volumes": [ diff --git a/postdeploy.sh b/postdeploy.sh deleted file mode 100755 index 62ad49d..0000000 --- a/postdeploy.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash - -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 initial deployment" - if gitea admin create-user --username "$ADMIN_USER" --password "$ADMIN_PASS" --email "$ADMIN_MAIL" --admin; then - echo "=====> root user added" - else - echo "=====> Failed to add root user" - exit 1 - fi - fi -} - -setup_letsencrypt_certs() { - set -eu - - if [ -d "/home/dokku/gitea/letsencrypt" ]; then - echo "=====> Generating let's encrypt certificates" - dokku letsencrypt "$APP" - fi -} - -main() { - set -eu - - setup_root_user - setup_letsencrypt_certs -} - -main diff --git a/predeploy.sh b/predeploy.sh index a10cfc4..0bd3e32 100755 --- a/predeploy.sh +++ b/predeploy.sh @@ -11,10 +11,41 @@ setup_db() { fi } +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 initial deployment" + if gitea admin create-user --username "$ADMIN_USER" --password "$ADMIN_PASS" --email "$ADMIN_MAIL" --admin; then + echo "=====> root user added" + else + echo "=====> Failed to add root user" + exit 1 + fi + fi +} + +setup_letsencrypt_certs() { + set -eu + + if [ -d "/home/dokku/gitea/letsencrypt" ]; then + echo "=====> Generating let's encrypt certificates" + dokku letsencrypt "$APP" + fi +} + main() { set -eu setup_db + setup_root_user + setup_letsencrypt_certs } main