Only do predeploy

This commit is contained in:
Luke Murphy 2020-03-15 09:05:13 +01:00
parent 402b30bafe
commit 1d24675009
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
3 changed files with 32 additions and 43 deletions

View File

@ -12,8 +12,7 @@
}, },
"scripts": { "scripts": {
"dokku": { "dokku": {
"predeploy": "bash /app/predeploy.sh", "predeploy": "bash /app/predeploy.sh"
"postdeploy": "bash /app/postdeploy.sh"
} }
}, },
"volumes": [ "volumes": [

View File

@ -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

View File

@ -11,10 +11,41 @@ setup_db() {
fi 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() { main() {
set -eu set -eu
setup_db setup_db
setup_root_user
setup_letsencrypt_certs
} }
main main