diff mbox series

[meta-oe] postgresql: update sysv init script

Message ID 20251020185401.3511011-1-skandigraun@gmail.com
State Under Review
Headers show
Series [meta-oe] postgresql: update sysv init script | expand

Commit Message

Gyorgy Sarvari Oct. 20, 2025, 6:54 p.m. UTC
postmaster binary doesn't seem to be installed by default, making the
sysv init script fail to start postgres.

Adjust it to use pg_ctl to start the service, just like its systemd
service counterpart.

Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
---
 meta-oe/recipes-dbs/postgresql/files/postgresql.init | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/meta-oe/recipes-dbs/postgresql/files/postgresql.init b/meta-oe/recipes-dbs/postgresql/files/postgresql.init
index 1791e68b58..6d20c60a56 100644
--- a/meta-oe/recipes-dbs/postgresql/files/postgresql.init
+++ b/meta-oe/recipes-dbs/postgresql/files/postgresql.init
@@ -56,7 +56,7 @@  pidfile="/var/run/postmaster.${PGPORT}.pid"
 script_result=0
 
 start(){
-	[ -x "$PGENGINE/postmaster" ] || exit 5
+	[ -x "$PGENGINE/pg_ctl" ] || exit 5
 
 	PSQL_START=$"Starting ${NAME} service: "
 
@@ -109,9 +109,9 @@  start(){
 
 	echo -n "$PSQL_START"
 	test x"$PG_OOM_ADJ" != x && echo "$PG_OOM_ADJ" > /proc/self/oom_score_adj
-	$SU -l postgres -c "$PGENGINE/postmaster -p '$PGPORT' -D '$PGDATA' ${PGOPTS} &" >> "$PGLOG" 2>&1 < /dev/null
-	sleep 2
-	pid=`head -n 1 "$PGDATA/postmaster.pid" 2>/dev/null`
+	$SU -l postgres -c "$PGENGINE/pg_ctl start -D '$PGDATA' -s -o '-p $PGPORT' ${PGOPTS} -w -t 300" >> ${PGLOG}
+
+        pid=`su postgres -c "pg_ctl status -D /var/lib/postgresql/data" | grep "PID:" | grep -o [0-9]*`
 	if [ "x$pid" != x ]
 	then
 		echo -n " [ OK ]"