Tune up bash script to configure

This commit is contained in:
Luke Murphy 2020-03-22 17:19:39 +01:00
parent 2fbc1dd683
commit 38322cc3b7
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

View File

@ -15,10 +15,11 @@ setup_root_user() {
set -eu
if [ ! -f "/data/gitea/conf/app.ini" ]; then
echo "-----> Missing app.ini, not setting up root user"
return
fi
user_count=$(sqlite3 /data/gitea/gitea.db "select count(*) from user;")
user_count=$(mysql -u"${DB_USER}" -p"${DB_PASSWD}" -h mysql --database="${DB_NAME}" -N -B -e "SELECT count(*) FROM user;")
if [[ "${user_count}" == "0" ]]; then
echo "-----> Setting up root user for initial deployment"
@ -35,6 +36,7 @@ setup_app_ini() {
set -eu
if [ ! -f "/data/gitea/conf/app.ini" ]; then
echo "-----> Missing app.ini, not setting up root user"
return
fi
@ -42,12 +44,14 @@ setup_app_ini() {
echo "-----> Using crudini to setup configuration"
crudini --del "$app_ini" database PATH
crudini --set "$app_ini" database DB_TYPE mysql
crudini --set "$app_ini" database HOST "${DB_HOST}"
crudini --set "$app_ini" database NAME "${DB_NAME}"
crudini --set "$app_ini" database USER "${DB_USER}"
crudini --set "$app_ini" database PASSWD "${DB_PASSWD}"
crudini --set "$app_ini" database SSL_MODE "disable"
crudini --set "$app_ini" server PROTOCOL "http"
crudini --set "$app_ini" server DOMAIN "${DOMAIN}"
crudini --set "$app_ini" server ROOT_URL "https://%(DOMAIN)s/"