From 86d1d6f6069bbcd0915e82098929fc079d0902ff Mon Sep 17 00:00:00 2001
From: kaloyane <kaloyane>
Date: Thu, 28 Jul 2011 16:31:37 +0000
Subject: [PATCH] [LMS-2411] first version of console installer. happy
 installation case works. error cases + upgrade still to be done.

SVN: 22282
---
 screening/build/build.xml                     | 31 ++++++++++++++---
 .../post-install/0-create-initial-users.sh    |  4 +--
 .../post-install/1-create-initial-database.sh |  2 +-
 screening/dist/tarball/README                 |  0
 screening/dist/tarball/console.properties     | 26 +++++++++++++++
 screening/dist/tarball/jul.config             |  4 +++
 screening/dist/tarball/run-console.sh         | 33 +++++++++++++++++++
 screening/dist/tarball/run-ui.sh              |  8 +++++
 8 files changed, 101 insertions(+), 7 deletions(-)
 create mode 100644 screening/dist/tarball/README
 create mode 100644 screening/dist/tarball/console.properties
 create mode 100644 screening/dist/tarball/jul.config
 create mode 100755 screening/dist/tarball/run-console.sh
 create mode 100755 screening/dist/tarball/run-ui.sh

diff --git a/screening/build/build.xml b/screening/build/build.xml
index 6d22150d490..c3510ad732c 100644
--- a/screening/build/build.xml
+++ b/screening/build/build.xml
@@ -26,6 +26,8 @@
   <!-- relative path referenced from within the installer compilation --> 
   <property name="installer.resourcedir" value="dist/tarball/installer" />
   <property name="installer.dist.dir" value="${basedir}/${dist}/installer" />
+  <property name="installer.jar.file" value="${basedir}/${dist}/openBIS-installer.jar" />
+	
 	<path id="izpack.classpath">
 	    <pathelement path="${classpath}"/>
 	    <fileset dir="${lib}">
@@ -44,8 +46,29 @@
         // Task for creating distributions
   -->
 	
-  <target name="dist" depends="create-installer, screening-api"/>
-  
+  <target name="dist" depends="create-installation-tarball, screening-api"/>
+
+	<target name="create-installation-tarball" depends="create-installer">
+	  <property name="tarball.file" value="${basedir}/${dist}/${tarball.basename}.tar.gz" />
+		
+		<tar destfile="${tarball.file}">
+		  <tarfileset dir="${basedir}/dist/tarball"
+		              prefix="${tarball.basename}/">
+		    <include name="*.*"/>
+		  	<exclude name="*.sh"/>
+		  </tarfileset>
+		  <tarfileset dir="${basedir}/dist/tarball"
+		              prefix="${tarball.basename}/"
+		  	          filemode="755">
+		    <include name="*.sh"/>
+		  </tarfileset>
+		  <tarfileset dir="${dist}"
+		              prefix="${tarball.basename}/">
+		    <include name="*-installer.jar"/>
+		  </tarfileset>
+		</tar>		
+	</target>
+	
   <target name="create-installer" depends="openbis.make-dist, make-full-dss-dist, dss-plugin-jar, datastore_server.make-plugin-dist, prepare-installer">
 
 		<mkdir dir="${installer.dist.dir}" />
@@ -106,8 +129,8 @@
 		<build-info revision="revision.number" version="version.number" clean="clean.flag" />
     <property name="dss.dist.file"
               value="${dist.file.prefix}${variant}-${version.number}-r${revision.number}.zip" />
-    <property name="installer.jar.file"
-              value="${basedir}/${dist}/openBIS-installer${variant}-${version.number}-r${revision.number}.jar" />
+		
+	  <property name="tarball.basename" value="openBIS-installation${variant}-${version.number}-r${revision.number}" />
 		
   	<zip update="true" destfile="${server.dist.file}">
   		<zipfileset file="${jars.to.be.signed.zip}"/>
diff --git a/screening/dist/admin/post-install/0-create-initial-users.sh b/screening/dist/admin/post-install/0-create-initial-users.sh
index cf1a35f2020..b8828e83428 100644
--- a/screening/dist/admin/post-install/0-create-initial-users.sh
+++ b/screening/dist/admin/post-install/0-create-initial-users.sh
@@ -10,13 +10,13 @@ createUser()
   username=$1
   password=$2
   
-  pushd .
+  pushd . > /dev/null
   cd $BASE/../../servers/openBIS-server/jetty
   
   echo "Creating user $username ..."
   ./bin/passwd.sh add -p "$password" $username
   
-  popd  
+  popd  > /dev/null
 }
 
 BASE=`dirname "$0"`
diff --git a/screening/dist/admin/post-install/1-create-initial-database.sh b/screening/dist/admin/post-install/1-create-initial-database.sh
index c63f664d011..cfaf3f86d43 100644
--- a/screening/dist/admin/post-install/1-create-initial-database.sh
+++ b/screening/dist/admin/post-install/1-create-initial-database.sh
@@ -22,4 +22,4 @@ createPostgresUserIfNeeded $USER
 createPostgresUserIfNeeded "OPENBIS_READONLY"
 
 $PSQL -U $DB_USER_NAME -c "create database $OPENBIS_DB with owner $USER template = template0 encoding = 'UNICODE'"
-$PSQL -U $USER -d $OPENBIS_DB -f $BASE/empty-screening-database.sql
\ No newline at end of file
+$PSQL -U $USER -d $OPENBIS_DB -f $BASE/empty-screening-database.sql > /dev/null
\ No newline at end of file
diff --git a/screening/dist/tarball/README b/screening/dist/tarball/README
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/screening/dist/tarball/console.properties b/screening/dist/tarball/console.properties
new file mode 100644
index 00000000000..23d98c35b2b
--- /dev/null
+++ b/screening/dist/tarball/console.properties
@@ -0,0 +1,26 @@
+#
+# The path where openBIS will be installed.
+# 
+# Example : 
+#     INSTALL_PATH=/home/openbis/
+#
+#   will result in the following directory structure
+#
+#   + /home/openbis
+#     +  bin/
+#     +  servers/
+#        + openBIS-server/
+#        + datastore_server/
+# 
+INSTALL_PATH=
+
+#
+# The path where openBIS will keep the imported data (e.g. images, analysis files)
+# and its incoming folders. 
+#
+DSS.ROOT-DIR=
+
+# Possible configuration options
+#   'local' - if the openBIS servers will only be accessed from this machine
+#   'server' - if the installation is meant to be accessible for remote users
+INSTALLATION_TYPE=local
\ No newline at end of file
diff --git a/screening/dist/tarball/jul.config b/screening/dist/tarball/jul.config
new file mode 100644
index 00000000000..60c529a927d
--- /dev/null
+++ b/screening/dist/tarball/jul.config
@@ -0,0 +1,4 @@
+#
+# Log configuration for the openBIS install process 
+#
+java.util.logging.ConsoleHandler.level=WARNING
\ No newline at end of file
diff --git a/screening/dist/tarball/run-console.sh b/screening/dist/tarball/run-console.sh
new file mode 100755
index 00000000000..6a56e502a14
--- /dev/null
+++ b/screening/dist/tarball/run-console.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+BASE=`dirname "$0"`
+if [ ${BASE#/} == ${BASE} ]; then
+    BASE="`pwd`/${BASE}"
+fi
+
+
+install_path_configured=$(grep -e "^INSTALL_PATH=.*\w.*$" $BASE/console.properties)
+if [ -z "$install_path_configured" ]; then
+    echo "The property INSTALL_PATH must be configured in $BASE/console.properties."
+    echo "Please edit the file and run the installation script again."
+    exit 1
+fi
+
+#
+# create 'admin' user
+#
+if [ -z "$ADMIN_PASSWORD" ]; then
+    read -s -p "Enter password for openBIS 'admin' user : " ADMIN_PASSWORD
+    echo ""
+    
+    read -s -p "Re-type password for openBIS 'admin' user : " ADMIN_PASSWORD2
+    echo ""
+    
+    if [ "$ADMIN_PASSWORD" -ne "$ADMIN_PASSWORD2" ]; then
+        echo "Administrator passwords do not match. Aborting installation."
+        exit 2
+    fi
+fi
+
+
+java -Djava.util.logging.config.file=$BASE/jul.config -DADMIN_PASSWORD=$ADMIN_PASSWORD -Dmerge.props.to.installation.vars=true -jar $BASE/openBIS-installer.jar -options-auto $BASE/console.properties
\ No newline at end of file
diff --git a/screening/dist/tarball/run-ui.sh b/screening/dist/tarball/run-ui.sh
new file mode 100755
index 00000000000..05c96a711a1
--- /dev/null
+++ b/screening/dist/tarball/run-ui.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+BASE=`dirname "$0"`
+if [ ${BASE#/} == ${BASE} ]; then
+    BASE="`pwd`/${BASE}"
+fi
+
+java -Djava.util.logging.config.file=$BASE/jul.config -jar $BASE/openBIS-installer.jar
\ No newline at end of file
-- 
GitLab