heroku_gitea/conf_script.sh

42 lines
1.2 KiB
Bash
Raw Normal View History

2024-10-24 21:44:18 +02:00
x#!/bin/bash
2024-10-24 21:13:36 +02:00
2024-10-24 21:38:09 +02:00
if [ -n "$HEROKU_APP_DEFAULT_DOMAIN_NAME" ]; then
APP_URL="https://${HEROKU_APP_DEFAULT_DOMAIN_NAME}"
2024-10-24 21:32:55 +02:00
else
if [ -f /app/app_link.txt ]; then
APP_URL=$(cat /app/app_link.txt)
else
2024-10-24 21:38:09 +02:00
echo "Neither HEROKU_APP_DEFAULT_DOMAIN_NAME nor /app/app_link.txt is available. Exiting."
2024-10-24 21:32:55 +02:00
exit 1
fi
2024-10-24 21:13:36 +02:00
fi
2024-10-24 21:32:55 +02:00
echo $APP_URL
2024-10-24 21:13:36 +02:00
if [[ $DATABASE_URL =~ ^postgres://([^:]+):([^@]+)@([^:]+):([0-9]+)/([^/]+)$ ]]; then
DB_USER="${BASH_REMATCH[1]}"
DB_PASS="${BASH_REMATCH[2]}"
DB_HOST="${BASH_REMATCH[3]}:${BASH_REMATCH[4]}"
DB_NAME="${BASH_REMATCH[5]}"
else
echo "DATABASE_URL parse error"
exit 1
fi
mkdir -p /var/lib/gitea/custom/conf
echo "[server]" > /var/lib/gitea/custom/conf/app.ini
echo "ROOT_URL = $APP_URL" >> /var/lib/gitea/custom/conf/app.ini
echo "[database]" >> /var/lib/gitea/custom/conf/app.ini
echo "DB_TYPE = postgres" >> /var/lib/gitea/custom/conf/app.ini
echo "HOST = $DB_HOST" >> /var/lib/gitea/custom/conf/app.ini
echo "NAME = $DB_NAME" >> /var/lib/gitea/custom/conf/app.ini
echo "USER = $DB_USER" >> /var/lib/gitea/custom/conf/app.ini
echo "PASSWD = $DB_PASS" >> /var/lib/gitea/custom/conf/app.ini
echo "SSL_MODE = require" >> /var/lib/gitea/custom/conf/app.ini
/usr/local/bin/gitea web --port $PORT
2024-10-24 21:25:33 +02:00