This repository has been archived on 2020-10-27. You can view files and clone it, but cannot push or open issues or pull requests.
git.autonomic.zone/postdeploy.sh

45 lines
951 B
Bash
Raw Normal View History

2020-03-12 14:01:36 +00:00
#!/bin/bash
set -eu -o pipefail
setup_root_user() {
set -eu
# TODO(decentral1se): fix to use sqlite3 database for now
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
echo "==> Setting up root user for first run"
if gitea create-admin --name "$ADMIN_USER" --password "$ADMIN_PASS" --email "$ADMIN_MAIL"; then
echo "==> root user added"
else
echo "==> Failed to add root user"
exit 1
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() {
set -eu
do_healthcheck
setup_root_user
}
# TODO(decentral1se): test manually for now...
# main