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
Luke Murphy 4eb972c703
Back to postdeploy
Release overrides the entrypoint.
2020-03-12 19:28:08 +01:00

38 lines
722 B
Bash
Executable File

#!/bin/bash
set -eu -o pipefail
setup_db() {
set -eu
echo "=====> Running database migration"
gitea migrate
}
setup_root_user() {
set -eu
user_count=$(sqlite3 /data/gitea/gitea.db "select count(*) from user;")
if [[ "${user_count}" == "0" ]]; then
echo "=====> Setting up root user for first run"
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
}
main() {
set -eu
if [ -f "/data/gitea/conf/app.ini" ]; then
setup_db
setup_root_user
fi
}
main