Tune up post deploy script

This commit is contained in:
Luke Murphy 2020-03-12 16:33:02 +01:00
parent 722e9af1e4
commit 291ae6591e
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

View File

@ -5,13 +5,12 @@ set -eu -o pipefail
setup_root_user() { setup_root_user() {
set -eu set -eu
# TODO(decentral1se): fix to use sqlite3 database for now user_count=$(sqlite3 /data/gitea.db "SELECT count(*) FROM user;")
user_count=$(mysql -u"${DB_USER}" -p"${DB_PASS}" -h mysql --database="${DB_NAME}" -N -B -e "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 first run"
if gitea create-admin --name "$ADMIN_USER" --password "$ADMIN_PASS" --email "$ADMIN_MAIL"; 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
echo "==> Failed to add root user" echo "==> Failed to add root user"
@ -20,25 +19,10 @@ setup_root_user() {
fi fi
} }
do_healthcheck() {
set -eu
echo "==> Running Gitea healthcheck"
while ! curl --fail "https://${DOMAIN}/healthcheck"; do
echo "==> Waiting for Gitea to come up"
sleep 1
done
echo "==> Gitea is up"
}
main() { main() {
set -eu set -eu
do_healthcheck
setup_root_user setup_root_user
} }
# TODO(decentral1se): test manually for now... main
# main