Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 378901 - Bad runscript in dev-db/postgresql-server
Summary: Bad runscript in dev-db/postgresql-server
Status: RESOLVED INVALID
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: FreeBSD (show other bugs)
Hardware: All FreeBSD
: Normal normal (vote)
Assignee: Gentoo/BSD Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-12 12:19 UTC by Dmitri Bogomolov
Modified: 2011-08-12 19:01 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitri Bogomolov 2011-08-12 12:19:44 UTC
I cannot stop postgresql because of bad runscript. Instaled dev-db/postgresql-server-8.4.7 and dev-db/postgresql-server-9.0.3.

Reproducible: Always

Steps to Reproduce:
1. /etc/init.d/postgresql-8.4 start
2. /etc/init.d/postgresql-8.4 stop

Actual Results:  
 * Stopping PostgreSQL (this can take up to 92 seconds) ...
[[: not found
 * NICE_QUIT disabled.
 * You really should have it enabled.
[[: not found
 * RUDE_QUIT disabled.
[[: not found
1.
 * Starting PostgreSQL ...
[[: not found
  PID  TT  STAT      TIME COMMAND
65956  ??  Ss     0:00.51 /usr/lib/postgresql-8.4/bin/postgres --silent-mode=true                          [ ok ]

2.
 * FORCE_QUIT disabled.
 * Unable to shutdown server.                                                                              [ !! ]
 * ERROR: postgresql-8.4 failed to stop

Expected Results:  
1.
postgresql-8.4  | * Starting PostgreSQL ...                                                                [ ok ]

2.
postgresql-8.4  | * Stopping PostgreSQL (this can take up to 92 seconds) ...
postgresql-8.4  |server stopped

Note, dev-db/postgresql-server-8.4.7 and dev-db/postgresql-server-9.0.3 are the last postgresql that can be installed on g/fbsd. Newer depends on masked >=sys-apps/sandbox-2.5.
Comment 1 Dmitri Bogomolov 2011-08-12 12:28:26 UTC
Excuse me, please. Actual results should be:

1:
# /etc/init.d/postgresql-9.0 start
 * Starting PostgreSQL ...
[[: not found                                                               [ ok ]
   PID  TT  STAT      TIME COMMAND
 1537  ??  Ss     0:00.56 /usr/lib/postgresql-9.0/bin/postgres --silent-mode=true

2:
# /etc/init.d/postgresql-9.0 stop
 * Stopping PostgreSQL (this can take up to 92 seconds) ...
[[: not found
 * NICE_QUIT disabled.
 * You really should have it enabled.
[[: not found
 * RUDE_QUIT disabled.
[[: not found
 * FORCE_QUIT disabled.
 * Unable to shutdown server.                                                                              [ !! ]
 * ERROR: postgresql-9.0 failed to stop
Comment 2 Naohiro Aota gentoo-dev 2011-08-12 12:50:17 UTC
postgresql team,

please fix your init scripts. Init scripts should not depend on bash features like "[[ ]]".
Comment 3 Aaron W. Swenson gentoo-dev 2011-08-12 13:06:20 UTC
Please check the latest revisions before submitting a bug. The Bash features being used in the init script was resolved quite some time ago.
Comment 4 Dmitri Bogomolov 2011-08-12 13:09:11 UTC
(In reply to comment #3)
> Please check the latest revisions before submitting a bug. The Bash features
> being used in the init script was resolved quite some time ago.

Latest versions cannot be installed on g/fbsd. I mentioned this above.
Comment 5 Naohiro Aota gentoo-dev 2011-08-12 13:17:23 UTC
I don't see it get fixed here, it's still using "[[ ]]":

http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-db/postgresql-server/files/postgresql.init-8.4-r1?revision=1.2&view=markup

and postgresql.init-9.0-r1 should have the same code.

$ cvs diff -u files/postgresql.init-8.4-r1 files/postgresql.init-9.0-r1
(no output, meaning two files are same)

sorry if I missed something.
Comment 6 Naohiro Aota gentoo-dev 2011-08-12 13:31:57 UTC
Surely, new bashism were introduced with -r1. Reopening the bug.

diff -u postgresql.init-8.4 postgresql.init-8.4-r1
<snip>
+    su -l ${PGUSER} \
+       -c "env PGDATA=\"${PGDATA}\" PGPORT=\"${PGPORT}\" ${PG_EXTRA_ENV} /usr/lib/postgresql-8.4/bin/pg_ctl start ${WAIT_FOR_START} -t ${START_TIMEOUT} -s -o '--silent-mode=true ${PGOPTS}'"
+    retval=$?
+
+    if [[ $retval != 0 ]] ; then
+       eend $retval
+       return $retval
+    fi
+
+    # The following is to catch the case of an already running server
+    # in which pg_ctl doesn't know to which server it connected to and
+    # falsely reports the server as 'up'
<snip>
+    ebegin "Stopping PostgreSQL (this can take up to $(( ${NICE_TIMEOUT} + ${RUDE_TIMEOUT} + ${FORCE_TIMEOUT} )) seconds)"
 
-       local retval
+    local retval
 
+    if [[ "${NICE_QUIT}" != "NO" ]] ; then
        su -l ${PGUSER} \
-               -c "env PGDATA=\"${PGDATA}\" /usr/lib/postgresql-8.4/bin/pg_ctl stop -t ${WAIT_FOR_DISCONNECT} -m smart"
-
<snip>
Comment 7 Aaron W. Swenson gentoo-dev 2011-08-12 17:20:38 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > Please check the latest revisions before submitting a bug. The Bash features
> > being used in the init script was resolved quite some time ago.
> 
> Latest versions cannot be installed on g/fbsd. I mentioned this above.

And yet it's still fixed. I will not reintroduce another bug to fix this one.

(In reply to comment #6)
> Surely, new bashism were introduced with -r1. Reopening the bug.

And surely it was fixed shortly after that as the latest ebuild revisions grab the scripts not from files/ but from here:

http://dev.gentoo.org/~titanofold/

You'll have to run the following command on the files:
sed 's/@SLOT@/9.0/g' -i postgresql.{confd,init}

Change out '9.0' for the actual slot you need.
Comment 8 Naohiro Aota gentoo-dev 2011-08-12 17:55:46 UTC
> (In reply to comment #6)
> > Surely, new bashism were introduced with -r1. Reopening the bug.
> 
> And surely it was fixed shortly after that as the latest ebuild revisions grab
> the scripts not from files/ but from here:
> 
> http://dev.gentoo.org/~titanofold/
> 
> You'll have to run the following command on the files:
> sed 's/@SLOT@/9.0/g' -i postgresql.{confd,init}
> 
> Change out '9.0' for the actual slot you need.

OK, I got it. Sorry for my misunderstanding.

Would the newest init scripts work for the older versions? If it works, may I change older ebuilds to grab init scripts from the url? (at least for BSD?)
Comment 9 Dmitri Bogomolov 2011-08-12 19:01:52 UTC
(In reply to comment #7)
> > Latest versions cannot be installed on g/fbsd. I mentioned this above.
> 
> And yet it's still fixed. I will not reintroduce another bug to fix this one.

So mask it and say goodbye to postgres in g/fbsd.