From 72d94d5ab2fd22020761e4eea82057c5a06cdd91 Mon Sep 17 00:00:00 2001
From: anttil <anttil>
Date: Wed, 21 May 2014 09:08:35 +0000
Subject: [PATCH] SSDM-290 Allow to create/update openBIS databases by database
 admins

SVN: 31564
---
 .../resource/installer/bin/init.sql.template  | 14 ++++++--
 .../doc/getting-started-with-openBIS.html     | 33 +++++++++++++++----
 2 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/installation/resource/installer/bin/init.sql.template b/installation/resource/installer/bin/init.sql.template
index 8c259d8c33a..302720f4bcf 100644
--- a/installation/resource/installer/bin/init.sql.template
+++ b/installation/resource/installer/bin/init.sql.template
@@ -1,7 +1,16 @@
 
 -- Execute the following SQL script as a database superuser
 
-create user DB_OWNER;
+DO
+$body$
+  begin
+  IF NOT EXISTS (SELECT * FROM pg_catalog.pg_user WHERE  usename = 'DB_OWNER')
+  THEN
+    create user DB_OWNER;
+  END IF;
+END;
+$body$;
+
 create database DB_NAME with owner DB_OWNER encoding 'UTF8' template=template0 tablespace=pg_default;
 alter database DB_NAME set default_with_oids = off; 
 alter database DB_NAME set join_collapse_limit = '32'; 
@@ -14,4 +23,5 @@ create table database_version_logs(db_version varchar(4) not null, module_name v
 insert into database_version_logs(db_version, run_status, run_status_timestamp) values ('0', 'SUCCESS', now());
 alter database DB_NAME owner to DB_OWNER;
 alter table database_version_logs owner to DB_OWNER;
-commit;
\ No newline at end of file
+commit;
+
diff --git a/openbis_standard_technologies/dist/tarball/installer/data/doc/getting-started-with-openBIS.html b/openbis_standard_technologies/dist/tarball/installer/data/doc/getting-started-with-openBIS.html
index 835ce9c589f..a6b81b5ecd5 100644
--- a/openbis_standard_technologies/dist/tarball/installer/data/doc/getting-started-with-openBIS.html
+++ b/openbis_standard_technologies/dist/tarball/installer/data/doc/getting-started-with-openBIS.html
@@ -21,17 +21,38 @@
   After the completion of the above command openBIS will be available at <a href=
   "https://localhost:8443/openbis">https://localhost:8443/openbis</a><br><br>
   
+  <div class="text">
   Note: by default, openBIS expects to be able to connect your PostgreSQL database as superuser 'postgres' without a password.
-  This is because openBIS needs to create its database user and schema.<br>
-  
-  If this assumption does not hold, the following command prints the SQL script that can be used to create the database:
+  This is because openBIS needs to create its database users and schemas.
+  If this assumption does not hold, the following commands print the SQL scripts that can be used to create the required databases manually:<br>
+  </div>
+
+  openBIS application server database:
   <div class="sourcecode">
     ${INSTALL_BIN_PATH}/init_database.sh openbis_prod openbis
+  </div> 
+  
+  DSS pathinfo database:
+  <div class="sourcecode">
     ${INSTALL_BIN_PATH}/init_database.sh pathinfo_prod openbis
-  </div> The first argument defines the database name, the second one the username that openBIS will be using to connect the corresponding database.<br>
-  Again, openBIS excepts the user(s) can connect the database without a password. If this is not the case, the password needs to be set to service.properties.<br>
-  Consult openBIS documentation for details.
+  </div> 
 
+  Imaging database (required only if technology 'screening' is enabled)
+  <div class="sourcecode">
+    ${INSTALL_BIN_PATH}/init_database.sh imaging_prod openbis
+  </div> 
+  
+  Proteomics database (required only if technology 'proteomics' is enabled)
+  <div class="sourcecode">
+    ${INSTALL_BIN_PATH}/init_database.sh proteomics_prod openbis
+  </div> 
+  
+  <div class="text"> 
+  The first argument of script 'init_database.sh' defines the database name. The second argument defines the username that openBIS will be using to connect the corresponding database.
+  Again, openBIS expects the user(s) can connect the database without a password. If this is not the case, the password needs to be set to service.properties.
+  Consult openBIS documentation for details.
+  </div>
+  
   <h3>B. Importing test data</h3>
 
   <p>By now you have a fully functional openBIS instance, but it makes little sense if it has no data in it.</p>
-- 
GitLab