#!/bin/sh while ! mariadb -hmariadb -u$GITEA_DATABASE_USR -p$GITEA_DATABASE_PWD $GITEA_DATABASE_NAME &>/dev/null; do echo "Gitea waiting db..." sleep 5 done ls -la echo "Initializing gitea..." adduser -D git addgroup --system git git mkdir -p /var/lib/gitea/{custom,data,log} chown -R git:git /var/lib/gitea/ chmod -R 750 /var/lib/gitea/ if [ ! -f "app.ini.bak" ]; then cp /tmp/app.ini . chown -R root:git . chmod -R 770 . sed -i "/NAME .*/c\NAME = $GITEA_DATABASE_NAME" app.ini sed -i "/USER .*/c\USER = $GITEA_DATABASE_USR" app.ini sed -i "/PASSWD .*/c\PASSWD = $GITEA_DATABASE_PWD" app.ini su git -c "gitea migrate" su git -c "gitea admin user create --username $GITEA_ADMIN_USR --password $GITEA_ADMIN_PWD --email $GITEA_ADMIN_MAIL --admin" fi echo "Launching gitea on localhost:3000" su git -c "gitea web --config /etc/gitea/app.ini"