meltedchoco commited on
Commit
1ff5f67
Β·
verified Β·
1 Parent(s): f3060d7

Update entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +5 -2
entrypoint.sh CHANGED
@@ -9,9 +9,13 @@ SEKAI_DB_URL="postgresql://sekai:sekai@/sekai?host=${PGHOST}&port=${PG_PORT}"
9
  # ── Initialize Postgres if needed ────────────────────────────────────
10
  if [ ! -f "${PGDATA}/PG_VERSION" ]; then
11
  echo "Initializing PostgreSQL database..."
 
 
12
  initdb --auth=trust --no-locale --encoding=UTF8 "${PGDATA}"
13
  fi
14
 
 
 
15
  # ── Cleanup stale pid if container restarted uncleanly ───────────────
16
  rm -f "${PGDATA}/postmaster.pid"
17
 
@@ -25,8 +29,7 @@ pg_ctl start -l "${PGDATA}/postgres.log" \
25
 
26
  # ── Create user and database if they don't exist ─────────────────────
27
  if ! psql -h "${PGHOST}" -p "${PG_PORT}" -U sekai -d sekai -c '\q' 2>/dev/null; then
28
- echo "Creating sekai user and database..."
29
- # psql -h "${PGHOST}" -p "${PG_PORT}" -d postgres -c "CREATE USER sekai;"
30
  psql -h "${PGHOST}" -p "${PG_PORT}" -d postgres -c "CREATE DATABASE sekai OWNER sekai;"
31
  fi
32
 
 
9
  # ── Initialize Postgres if needed ────────────────────────────────────
10
  if [ ! -f "${PGDATA}/PG_VERSION" ]; then
11
  echo "Initializing PostgreSQL database..."
12
+ mkdir -p "${PGDATA}"
13
+ chmod 700 "${PGDATA}" # ← postgres requires exactly 0700
14
  initdb --auth=trust --no-locale --encoding=UTF8 "${PGDATA}"
15
  fi
16
 
17
+ chmod 700 "${PGDATA}" # ← also fix on restart if perms drifted
18
+
19
  # ── Cleanup stale pid if container restarted uncleanly ───────────────
20
  rm -f "${PGDATA}/postmaster.pid"
21
 
 
29
 
30
  # ── Create user and database if they don't exist ─────────────────────
31
  if ! psql -h "${PGHOST}" -p "${PG_PORT}" -U sekai -d sekai -c '\q' 2>/dev/null; then
32
+ echo "Creating sekai database..."
 
33
  psql -h "${PGHOST}" -p "${PG_PORT}" -d postgres -c "CREATE DATABASE sekai OWNER sekai;"
34
  fi
35