2024-10-18 22:54:52 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-10-23 18:37:55 +02:00
|
|
|
# Database type
|
2024-10-18 22:54:52 +02:00
|
|
|
DB_TYPE=postgres
|
|
|
|
|
2024-10-23 18:50:10 +02:00
|
|
|
# SSL mode
|
|
|
|
SSL_MODE=require
|
|
|
|
|
2024-10-23 18:37:55 +02:00
|
|
|
# Extract database credentials from DATABASE_URL
|
2024-10-18 22:54:52 +02:00
|
|
|
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
|
2024-10-23 18:37:55 +02:00
|
|
|
echo "Invalid DATABASE_URL: $DATABASE_URL"
|
2024-10-18 22:54:52 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-10-23 18:43:49 +02:00
|
|
|
# Get app url
|
|
|
|
FILE=/app/heroku-app.txt
|
2024-10-23 18:46:09 +02:00
|
|
|
ROOT_URL=$(cat $FILE)
|
2024-10-23 18:43:49 +02:00
|
|
|
|
|
|
|
# Custom configuration
|
2024-10-23 18:37:55 +02:00
|
|
|
mkdir -p /var/lib/gitea/custom/conf
|
2024-10-18 22:54:52 +02:00
|
|
|
|
2024-10-23 18:46:09 +02:00
|
|
|
echo $ROOT_URL
|
|
|
|
|
2024-10-23 18:43:49 +02:00
|
|
|
printf "[server]\nROOT_URL = $ROOT_URL\n" > /var/lib/gitea/custom/conf/app.ini
|
2024-10-23 18:50:10 +02:00
|
|
|
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
|
2024-10-23 18:07:28 +02:00
|
|
|
|
2024-10-23 18:39:46 +02:00
|
|
|
/usr/local/bin/gitea web -port $PORT
|