Use crudini to configure
This commit is contained in:
parent
7b67d04fa2
commit
db4ad413d3
@ -83,6 +83,7 @@
|
|||||||
app: gitea
|
app: gitea
|
||||||
restart: false
|
restart: false
|
||||||
config:
|
config:
|
||||||
|
DOMAIN: "git.autonomic.zone"
|
||||||
ADMIN_MAIL: "{{ autonomic_admin_mail }}"
|
ADMIN_MAIL: "{{ autonomic_admin_mail }}"
|
||||||
ADMIN_PASS: "{{ autonomic_admin_pass }}"
|
ADMIN_PASS: "{{ autonomic_admin_pass }}"
|
||||||
ADMIN_USER: "{{ autonomic_admin_user }}"
|
ADMIN_USER: "{{ autonomic_admin_user }}"
|
||||||
|
@ -6,7 +6,7 @@ setup_db() {
|
|||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
if [ -f "/data/gitea/conf/app.ini" ]; then
|
if [ -f "/data/gitea/conf/app.ini" ]; then
|
||||||
echo "=====> Running database migration"
|
echo "-----> Running database migration"
|
||||||
gitea migrate
|
gitea migrate
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -21,21 +21,47 @@ setup_root_user() {
|
|||||||
user_count=$(sqlite3 /data/gitea/gitea.db "select count(*) from user;")
|
user_count=$(sqlite3 /data/gitea/gitea.db "select count(*) from user;")
|
||||||
|
|
||||||
if [[ "${user_count}" == "0" ]]; then
|
if [[ "${user_count}" == "0" ]]; then
|
||||||
echo "=====> Setting up root user for initial deployment"
|
echo "-----> Setting up root user for initial deployment"
|
||||||
if gitea admin create-user --username "$ADMIN_USER" --password "$ADMIN_PASS" --email "$ADMIN_MAIL" --admin; 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"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setup_app_ini() {
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
if [ ! -f "/data/gitea/conf/app.ini" ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
declare app_ini="/data/gitea/conf/app.ini"
|
||||||
|
|
||||||
|
echo "-----> Setting up root user for initial deployment"
|
||||||
|
|
||||||
|
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/"
|
||||||
|
crudini --set "$app_ini" sserver HTTP_ADDR ""
|
||||||
|
crudini --set "$app_ini" sserver HTTP_PORT "3000"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
setup_db
|
setup_db
|
||||||
setup_root_user
|
setup_root_user
|
||||||
|
setup_app_ini
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main
|
||||||
|
Reference in New Issue
Block a user