From: Thierry Parmentelat Date: Thu, 16 Apr 2015 11:03:11 +0000 (+0200) Subject: do not rely on /etc/myplc-release to start or stop postgresql X-Git-Tag: sfa-3.1-15~1 X-Git-Url: http://git.onelab.eu/?p=sfa.git;a=commitdiff_plain;h=79241b01e911ab84b083a32d50745007964b8c74 do not rely on /etc/myplc-release to start or stop postgresql instead: start it when not yet running, and record that in /etc/sfa/postgresql-started so we can stop it properly --- diff --git a/init.d/sfa b/init.d/sfa index ae4aa9c5..e3b80f90 100755 --- a/init.d/sfa +++ b/init.d/sfa @@ -36,6 +36,7 @@ function debian_get_postgresql_versions () { } #################### +POSTGRESQL_STARTED=/etc/sfa/postgresql-started if [ -f /etc/redhat-release ] ; then # source function library . /etc/init.d/functions @@ -233,9 +234,13 @@ function db_start () { ######## Start up the server # not too nice, but.. when co-located with myplc we'll let it start/stop postgresql - if [ ! -f /etc/myplc-release ] ; then - echo STARTING... + if [ ! postgresql_check ] ; then service postgresql start >& /dev/null + MESSAGE=$"Starting PostgreSQL server" + echo -n "$MESSAGE" + [ "$ERRORS" == 0 ] && success "$MESSAGE" || failure "$MESSAGE" ; echo + # best-effort to make sure we turn it back off when running stop + touch $POSTGRESQL_STARTED fi postgresql_check check @@ -270,12 +275,13 @@ function db_stop () { [ "$SFA_DB_ENABLED" == 1 -o "$SFA_DB_ENABLED" == True ] || return # not too nice, but.. when co-located with myplc we'll let it start/stop postgresql - if [ ! -f /etc/myplc-release ] ; then + if [ -f $POSTGRESQL_STARTED ] ; then service postgresql stop >& /dev/null check MESSAGE=$"Stopping PostgreSQL server" echo -n "$MESSAGE" [ "$ERRORS" == 0 ] && success "$MESSAGE" || failure "$MESSAGE" ; echo + rm -f $POSTGRESQL_STARTED fi }