]> git.pld-linux.org Git - packages/postgresql.git/commitdiff
- use awk instead of sed (to be consistent with rc-scripts dependencies)
authorJakub Bogusz <qboosh@pld-linux.org>
Tue, 19 Feb 2008 21:18:27 +0000 (21:18 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
- more sane way to check for PID existence (grep can be easily misleaded)

Changed files:
    postgresql.init -> 1.74

postgresql.init

index 34b2d2a6290d27d70742e187a29f0d015e3eb7c5..727c2751fcd77b6ed38d50d106775079005ab3b2 100644 (file)
@@ -79,7 +79,7 @@ pgstatus() {
        elif [ $status -eq 0 ]; then
                PG_STATUS="running"
         # or maybe grab it from postmaster.pid file?
-               PG_PID=`echo "$output" | sed 's/^pg_ctl:.*PID: \([0-9]\+\).*/\1/' | head -n 1`
+               PG_PID=$(echo "$output" | awk '/PID: / { match($0, "PID: [0-9]+"); print substr($0,RSTART+5,RLENGTH-5) }')
        fi
 }
 
@@ -120,7 +120,7 @@ start() {
                if [ "$PG_STATUS" = "running" ]; then
                        # pg_ctl status can misinform us about postgresql status
                        # so let's check if postmaster is really alive
-                       if ps ax | grep -v grep | grep -q "$PG_PID"; then
+                       if ps -p "$PG_PID" >/dev/null; then
                                msg_already_running "PostgreSQL $pgdir"
                        else
                                # pg_ctl has misinformed us about postgresql status;
@@ -145,7 +145,7 @@ stop() {
                        msg_stopping "PostgreSQL $pgdir"
                        busy
                        # is postgresql really alive?
-                       if ps ax | grep -v grep | grep -q "$PG_PID"; then
+                       if ps -p "$PG_PID" >/dev/null; then
                                TMPDIR=/tmp su postgres -c "/usr/bin/pg_ctl -w -D $pgdir stop -m fast 2>&1 >/dev/null"
                                pgstatus "$pgdir"
                                if [ "$PG_STATUS" != "not running" ]; then
@@ -200,7 +200,7 @@ case "$action" in
                        msg_reloading "PostgreSQL $pgdir"
                        busy
                        # is postgresql really alive?
-                       if ps ax | grep -v grep | grep -q "$PG_PID"; then
+                       if ps -p "$PG_PID" >/dev/null; then
                                TMPDIR=/tmp su postgres -c "/usr/bin/pg_ctl -D $pgdir restart 2>&1 >/dev/null"
                                        pgstatus "$pgdir"
                                if [ "$PG_STATUS" = "running" ]; then
This page took 0.352427 seconds and 4 git commands to generate.