initial commit - code moved to separate repo
This commit is contained in:
27
_deploy/setup-postgres.sh
Normal file
27
_deploy/setup-postgres.sh
Normal file
@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Update APK repositories
|
||||
apk update
|
||||
|
||||
# Install PostgreSQL
|
||||
apk add postgresql postgresql-client
|
||||
|
||||
# Create a new database directory
|
||||
mkdir -p /var/lib/postgresql/data
|
||||
|
||||
# Initialize the database
|
||||
su - postgres -c "initdb /var/lib/postgresql/data"
|
||||
|
||||
# Start PostgreSQL
|
||||
su - postgres -c "pg_ctl start -D /var/lib/postgresql/data -l logfile"
|
||||
|
||||
# Create a new user and database
|
||||
su - postgres -c "psql -c \"CREATE USER myuser WITH PASSWORD 'mypassword';\""
|
||||
su - postgres -c "psql -c \"CREATE DATABASE mydb OWNER myuser;\""
|
||||
|
||||
# Enable remote connections (optional)
|
||||
echo "host all all 0.0.0.0/0 md5" >> /var/lib/postgresql/data/pg_hba.conf
|
||||
echo "listen_addresses='*'" >> /var/lib/postgresql/data/postgresql.conf
|
||||
|
||||
# Restart PostgreSQL to apply changes
|
||||
su - postgres -c "pg_ctl restart -D /var/lib/postgresql/data"
|
Reference in New Issue
Block a user