Browse code

Add pg_createcluster creating process for psql version after 9.3

postgresql 9.3 don't create /etc/postgresql and related conf file by
default. So we need start the pg_createcluster in devstack if has not
started after package installed.

Change-Id: I2b348658d79b23b5f21871b33d8023499b2fb956
Close-bug: #1552051
(cherry picked from commit 174986db21ebf3c20ba28c873e855629737a5b86)

Yalei Wang authored on 2016/03/02 12:28:06
Showing 1 changed files
... ...
@@ -47,7 +47,7 @@ function recreate_database_postgresql {
47 47
 }
48 48
 
49 49
 function configure_database_postgresql {
50
-    local pg_conf pg_dir pg_hba root_roles
50
+    local pg_conf pg_dir pg_hba root_roles version
51 51
     echo_summary "Configuring and starting PostgreSQL"
52 52
     if is_fedora; then
53 53
         pg_hba=/var/lib/pgsql/data/pg_hba.conf
... ...
@@ -56,6 +56,13 @@ function configure_database_postgresql {
56 56
             sudo postgresql-setup initdb
57 57
         fi
58 58
     elif is_ubuntu; then
59
+        version=`psql --version | cut -d ' ' -f3 | cut -d. -f1-2`
60
+        if vercmp $version '>=' 9.3; then
61
+            if [ -z "`pg_lsclusters -h`" ]; then
62
+                echo 'No PostgreSQL clusters exist; will create one'
63
+                sudo pg_createcluster $version main --start
64
+            fi
65
+        fi
59 66
         pg_dir=`find /etc/postgresql -name pg_hba.conf|xargs dirname`
60 67
         pg_hba=$pg_dir/pg_hba.conf
61 68
         pg_conf=$pg_dir/postgresql.conf