mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
feat: Switch to postgres
Migrate from MariaDB to PostgreSQL. Signed-off-by: moson <moson@archlinux.org>
This commit is contained in:
parent
eca8bbf515
commit
122df968dc
64 changed files with 1467 additions and 1441 deletions
34
docker/postgres-entrypoint.sh
Executable file
34
docker/postgres-entrypoint.sh
Executable file
|
@ -0,0 +1,34 @@
|
|||
#!/bin/bash
|
||||
set -eou pipefail
|
||||
|
||||
PGDATA=/var/lib/postgres/data
|
||||
DATABASE="aurweb"
|
||||
|
||||
# Initialize and setup postgres
|
||||
if [ ! -f "$PGDATA/../init" ]; then
|
||||
echo "Preparing postgres instance..."
|
||||
touch $PGDATA/../init
|
||||
|
||||
# Init db directory
|
||||
su postgres -c "pg_ctl initdb -D $PGDATA"
|
||||
su postgres -c "echo \"listen_addresses='*'\" >> $PGDATA/postgresql.conf"
|
||||
su postgres -c "echo \"host all all 0.0.0.0/0 scram-sha-256\" >> $PGDATA/pg_hba.conf"
|
||||
install -d -o postgres -g postgres /run/postgresql
|
||||
|
||||
# Start postgres
|
||||
su postgres -c "pg_ctl start -D $PGDATA"
|
||||
|
||||
# Configure database & user
|
||||
echo "Taking care of primary database '$DATABASE'..."
|
||||
su postgres -c "psql -c \"create database $DATABASE;\""
|
||||
su postgres -c "psql -c \"create role aur superuser login password 'aur';\"";
|
||||
|
||||
# Provision database
|
||||
python -m aurweb.initdb 2>/dev/null || /bin/true
|
||||
|
||||
# Stop postgres
|
||||
su postgres -c "pg_ctl stop -D $PGDATA"
|
||||
|
||||
fi
|
||||
|
||||
exec "$@"
|
Loading…
Add table
Add a link
Reference in a new issue