[rhmessaging-commits] rhmessaging commits: r4372 - mgmt/trunk/cumin/bin.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Fri Oct 8 09:31:58 EDT 2010


Author: tmckay
Date: 2010-10-08 09:31:58 -0400 (Fri, 08 Oct 2010)
New Revision: 4372

Modified:
   mgmt/trunk/cumin/bin/cumin-database
Log:
Modify the install function to use the postgresql service interface to initialize the database.  The interface changed between PostgreSQL 8.3 and 8.4; support both.


Modified: mgmt/trunk/cumin/bin/cumin-database
===================================================================
--- mgmt/trunk/cumin/bin/cumin-database	2010-10-08 02:40:04 UTC (rev 4371)
+++ mgmt/trunk/cumin/bin/cumin-database	2010-10-08 13:31:58 UTC (rev 4372)
@@ -158,11 +158,23 @@
         exit 1
     fi
 
-    run "initdb --pgdata='$pgdata' --auth='ident sameuser'" postgres
-    run "mkdir '$pglog'" postgres
-    run "chmod 700 '$pglog'" postgres
+    # On older versions of Postgres (before 8.4), initdb does not exist but
+    # using the start option will initialize the database, then start it.
+    # Try initdb first, and if it fails try start followed by stop.  This
+    # should leave the database and the service in the same state on all
+    # 8.x versions of Postgres.
+    set +e
+    echo -e "\nAttempting to use initdb option..."
+    run "/sbin/service postgresql initdb"
+    if [ $? -ne 0 ]; then
+        echo -e "\ninitdb option not supported, using start..."
+        run "/sbin/service postgresql start"
+        run "/sbin/service postgresql stop"
+    fi
 
-    /sbin/restorecon -R "$pgdata"
+    # now check again, to make sure one of the two methods worked
+    check-initialized &> /dev/null || { echo "Database initialization failed."; exit 1; }
+    set -e
 }
 
 function configure {



More information about the rhmessaging-commits mailing list