pleroma/postgresql/setup.sh

22 lines
987 B
Bash
Raw Normal View History

2021-08-25 08:39:26 -06:00
#!/bin/bash
export SHELL="/bin/bash"
#Database Setup
mkdir /run/postgresql
2021-11-02 13:10:27 -06:00
#mkdir -p /var/lib/postgresql/13/main
2021-08-25 08:39:26 -06:00
chown -R postgres:postgres /run/postgresql/
chown -R postgres:postgres /var/lib/postgresql
chown -R postgres:postgres /var/log/postgresql
2021-11-02 13:10:27 -06:00
#su postgres -s $SHELL -lc "mkdir /var/lib/postgresql/data;chmod 0700 /var/lib/postgresql/13/main"
su postgres -s $SHELL -lc "initdb --auth-host=trust -D /var/lib/postgresql/data"
cp -f /etc/postgresql.conf /var/lib/postgresql/data/
echo "host all all 0.0.0.0/0 md5" >> /var/lib//postgresql/data/pg_hba.conf
chown -R postgres:postgres /var/lib/postgresql
su postgres -s $SHELL -lc "pg_ctl start -D /var/lib/postgresql/data"
2021-08-25 08:39:26 -06:00
sleep 5
2022-02-01 21:26:36 -07:00
2021-08-25 08:39:26 -06:00
echo "create user root with encrypted password 'sql';"| su postgres -s $SHELL -lc psql
2022-02-01 21:26:36 -07:00
echo "ALTER ROLE root SUPERUSER;" | su postgres -s $SHELL -lc psql
echo "CREATE DATABASE pleroma with template = template0 OWNER = root ENCODING = 'UTF8';" | su postgres -s $SHELL -lc psql
2021-08-25 08:39:26 -06:00
touch /configured.txt