Tweak usage of plugins

This commit is contained in:
Luke Murphy 2020-03-15 08:42:50 +01:00
parent 513843b395
commit aa49f2d295
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
3 changed files with 22 additions and 14 deletions

View File

@ -4,11 +4,7 @@
"repository": "https://gitlab.com/autonomic-cooperative/gitea-dokku", "repository": "https://gitlab.com/autonomic-cooperative/gitea-dokku",
"dokku": { "dokku": {
"plugins": [ "plugins": [
{ "name": "proxy", "commands": ["proxy:ports-add http:80:3000"] }, { "name": "proxy", "commands": ["proxy:ports-add http:80:3000"] }
{
"name": "letsencrypt",
"commands": ["letsencrypt gitea", "letsencrypt:cron-job --add"]
}
] ]
}, },
"scripts": { "scripts": {

View File

@ -5,10 +5,14 @@ set -eu -o pipefail
setup_root_user() { setup_root_user() {
set -eu set -eu
if [ ! -f "/data/gitea/conf/app.ini" ]; then
return
fi
user_count=$(sqlite3 /data/gitea/gitea.db "select count(*) from user;") user_count=$(sqlite3 /data/gitea/gitea.db "select count(*) from user;")
if [[ "${user_count}" == "0" ]]; then 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 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 else
@ -18,12 +22,20 @@ setup_root_user() {
fi fi
} }
main() { setup_letsencrypt_certs() {
set -eu set -eu
if [ -f "/data/gitea/conf/app.ini" ]; then if [ -d "/home/dokku/gitea/letsencrypt" ]; then
setup_root_user echo "=====> Generating let's encrypt certificates"
dokku letsencrypt gitea
fi fi
} }
main() {
set -eu
setup_root_user
setup_letsencrypt_certs
}
main main

View File

@ -5,16 +5,16 @@ set -eu -o pipefail
setup_db() { setup_db() {
set -eu set -eu
echo "=====> Running database migration" if [ -f "/data/gitea/conf/app.ini" ]; then
gitea migrate echo "=====> Running database migration"
gitea migrate
fi
} }
main() { main() {
set -eu set -eu
if [ -f "/data/gitea/conf/app.ini" ]; then setup_db
setup_db
fi
} }
main main