mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-01-04 10:40:23 -06:00
22 lines
695 B
Bash
22 lines
695 B
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
# Initialize PostgreSQL database
|
|
if [ ! -f /var/lib/postgresql/data/PG_VERSION ]; then
|
|
echo "Initializing PostgreSQL database..."
|
|
su - postgres -c "initdb -D /var/lib/postgresql/data"
|
|
su - postgres -c "pg_ctl -D /var/lib/postgresql/data -l logfile start"
|
|
|
|
# Create database and user
|
|
su - postgres -c "createdb timetracker"
|
|
su - postgres -c "createuser -s timetracker"
|
|
|
|
# Run initialization SQL
|
|
su - postgres -c "psql -d timetracker -f /app/docker/init.sql"
|
|
|
|
su - postgres -c "pg_ctl -D /var/lib/postgresql/data stop"
|
|
echo "PostgreSQL database initialized successfully"
|
|
else
|
|
echo "PostgreSQL database already exists"
|
|
fi
|