Changes before error encountered

Agent-Logs-Url: https://github.com/nextcloud/all-in-one/sessions/6f198732-63c3-41b7-8b2e-1b5fa565ee21

Co-authored-by: szaimen <42591237+szaimen@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-27 02:12:13 +00:00
committed by GitHub
parent 5cbdb00ff4
commit 312acddf27
3 changed files with 33 additions and 30 deletions

View File

@@ -10,21 +10,18 @@ fi
export TZ="${TZ:-Etc/UTC}"
PGDATA="/var/lib/postgresql/data"
# Fix runtime directory permissions (tmpfs mounts start owned by root)
chown postgres:postgres /var/run/postgresql
chmod 775 /var/run/postgresql
# Initialize PostgreSQL data directory on first run
# Initialize PostgreSQL data directory on first run.
# No su/chown needed — we already own PGDATA (uid=10001 owns the volume).
if [ -z "$(ls -A "$PGDATA" 2>/dev/null)" ]; then
echo "Initializing PostgreSQL database for Windmill..."
# Ensure the data directory is owned by postgres before initdb
chown postgres:postgres "$PGDATA"
initdb -D "$PGDATA" \
--username=windmill \
--auth-local=trust \
--auth-host=trust \
--no-instructions
# Run initdb as the postgres user
su postgres -s /bin/bash -c "initdb -D '$PGDATA' --username=postgres --auth-local=trust --auth-host=trust --no-instructions"
# Allow connections from localhost without a password
# Allow local connections without a password; listen only on localhost
cat > "$PGDATA/pg_hba.conf" << 'EOF'
# TYPE DATABASE USER ADDRESS METHOD
local all all trust
@@ -32,16 +29,16 @@ host all all 127.0.0.1/32 trust
host all all ::1/128 trust
EOF
# Only listen on localhost; the database is not exposed externally
cat >> "$PGDATA/postgresql.conf" << 'EOF'
listen_addresses = 'localhost'
EOF
# Start PostgreSQL temporarily to create the windmill database and user
su postgres -s /bin/bash -c "pg_ctl -D '$PGDATA' start -w -o '-k /var/run/postgresql'"
su postgres -s /bin/bash -c "psql -h /var/run/postgresql -c \"CREATE USER windmill;\""
su postgres -s /bin/bash -c "psql -h /var/run/postgresql -c \"CREATE DATABASE windmill OWNER windmill;\""
su postgres -s /bin/bash -c "pg_ctl -D '$PGDATA' stop"
# Start PostgreSQL temporarily to create the windmill database, then stop it.
# supervisord will restart it properly afterward.
pg_ctl -D "$PGDATA" start -w -o "-k /var/run/postgresql"
psql -h /var/run/postgresql -U windmill postgres \
-c "CREATE DATABASE windmill OWNER windmill;"
pg_ctl -D "$PGDATA" stop -w
echo "PostgreSQL initialization complete."
fi