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/sbin/entrypoint.sh

44 lines
827 B
Bash
Raw Normal View History

2020-03-15 11:46:13 +00:00
#!/bin/bash
2020-03-15 11:41:24 +00:00
2020-03-15 11:46:13 +00:00
set -eu -o pipefail
setup_db() {
set -eu
if [ -f "/data/gitea/conf/app.ini" ]; then
echo "=====> Running database migration"
gitea migrate
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"
2020-03-15 12:11:35 +00:00
if gitea admin create-user --username "$ADMIN_USER" --password "$ADMIN_PASS" --email "$ADMIN_MAIL" --admin; then
2020-03-15 11:46:13 +00:00
echo "=====> root user added"
else
echo "=====> Failed to add root user"
exit 1
fi
fi
}
main() {
set -eu
setup_db
setup_root_user
}
main
2020-03-15 11:41:24 +00:00
/usr/bin/entrypoint "$@"