heroku-gitea/parse_db_url.sh
awieczarek 6ef5d5d1e6 Test
2024-10-23 13:02:27 +02:00

28 lines
1.0 KiB
Bash

#!/bin/sh
DATABASE_URL=$(echo $DATABASE_URL)
DB_TYPE="postgres"
USER=$(echo $DATABASE_URL | sed -e 's,.*//\(.*\):.*@.*,\1,')
PASSWD=$(echo $DATABASE_URL | sed -e 's,.*//.*:\(.*\)@.*,\1,')
HOST=$(echo $DATABASE_URL | sed -e 's,.*@\(.*\):\(.*\)/.*,\1,')
PORT=$(echo $DATABASE_URL | sed -e 's,.*@.*:\(.*\)/.*,\1,')
NAME=$(echo $DATABASE_URL | sed -e 's,.*/\(.*\)$,\1,')
SSL_MODE="require"
printf "\n[server]\n" >> /var/lib/gitea/custom/conf/app.ini
printf "HTTP_PORT = $PORT\n" > /var/lib/gitea/custom/conf/app.ini
printf "[database]\n" > /var/lib/gitea/custom/conf/app.ini
printf "DB_TYPE = $DB_TYPE\n" >> /var/lib/gitea/custom/conf/app.ini
printf "HOST = $HOST:$PORT\n" >> /var/lib/gitea/custom/conf/app.ini
printf "NAME = $NAME\n" >> /var/lib/gitea/custom/conf/app.ini
printf "USER = $USER\n" >> /var/lib/gitea/custom/conf/app.ini
printf "PASSWD = $PASSWD\n" >> /var/lib/gitea/custom/conf/app.ini
printf "SSL_MODE = $SSL_MODE\n" >> /var/lib/gitea/custom/conf/app.ini
cat /var/lib/gitea/custom/conf/app.ini
/usr/local/bin/gitea web -port $PORT