32 lines
860 B
Bash
32 lines
860 B
Bash
#!/bin/bash
|
|
|
|
# Database type
|
|
DB_TYPE=postgres
|
|
|
|
# SSL mode
|
|
SSL_MODE=require
|
|
|
|
# Extract database credentials from DATABASE_URL
|
|
if [[ $DATABASE_URL =~ ^postgres://([^:]*):([^@]*)@([^:]*):([0-9]+)/([^/]*)$ ]]; then
|
|
USER="${BASH_REMATCH[1]}"
|
|
PASSWD="${BASH_REMATCH[2]}"
|
|
HOST="${BASH_REMATCH[3]}:${BASH_REMATCH[4]}"
|
|
NAME="${BASH_REMATCH[5]}"
|
|
else
|
|
echo "Invalid DATABASE_URL: $DATABASE_URL"
|
|
exit 1
|
|
fi
|
|
|
|
# Get app url
|
|
FILE=/app/heroku-app.txt
|
|
ROOT_URL=$(cat $FILE)
|
|
|
|
# Custom configuration
|
|
mkdir -p /var/lib/gitea/custom/conf
|
|
|
|
# Add custom configuration
|
|
printf "[server]\nROOT_URL = $ROOT_URL\n" > /var/lib/gitea/custom/conf/app.ini
|
|
printf "[database]\nDB_TYPE = $DB_TYPE\nHOST = $HOST\nNAME = $NAME\nUSER = $USER\nPASSWD = $PASSWD\nSSL_MODE = $SSL_MODE\n" >> /var/lib/gitea/custom/conf/app.ini
|
|
|
|
# Start Gitea
|
|
/usr/local/bin/gitea web -port $PORT |