From e922d689f4b6b5444edca511c0ee2d2518976382 Mon Sep 17 00:00:00 2001
From: Sonia Zorba <zorba@oats.inaf.it>
Date: Fri, 26 Jan 2018 11:04:00 +0100
Subject: [PATCH] Created installation scripts, removed hardcoded configuration

---
 .gitignore                                    |  13 ++
 .gitlab-ci.yml                                |   2 +
 README.md                                     |  52 ++---
 TASMAN-bom/pom.xml                            |  53 +++++
 TASMAN-core/pom.xml                           |  65 +++----
 .../test/java/it/inaf/ia2/tsm/TestAll.java    |  26 ++-
 TASMAN-embedded/pom.xml                       |  17 +-
 .../src/main/resources/app.properties         |   2 +-
 TASMAN-webapp/pom.xml                         |  33 ++--
 .../src/main/resources/webapp.properties      |   6 +-
 build.sh                                      | 182 ++++++++++++++++++
 config.properties.example                     |   2 +
 install.sh => install_template.sh             |  60 +++---
 test.properties.example                       |  12 ++
 update_version.sh                             |  22 +++
 15 files changed, 411 insertions(+), 136 deletions(-)
 create mode 100644 .gitignore
 create mode 100644 .gitlab-ci.yml
 create mode 100644 TASMAN-bom/pom.xml
 create mode 100755 build.sh
 create mode 100644 config.properties.example
 rename install.sh => install_template.sh (88%)
 mode change 100755 => 100644
 create mode 100644 test.properties.example
 create mode 100755 update_version.sh

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b1b714b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,13 @@
+/TASMAN-webapp/nb-configuration.xml
+/TASMAN-webapp/nbactions.xml
+/TASMAN-webapp/faces-config.NavData
+/TASMAN-core/target/
+/TASMAN-webapp/target/
+/TASMAN-core/nb-configuration.xml
+/TASMAN-embedded/target/
+/TASMAN-core/nbproject/
+/TASMAN-bom/target/
+config.properties
+test.properties
+/**/pom.xml.versionsBackup
+install.sh
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..ba91c93
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,2 @@
+build:
+  script: "cd TASMAN-core; mvn clean install -P Test -Dmysql_host=localhost -Dmysql_port=3306 -Dmysql_user=tasman_tester -D mysql_password=tasman_tester -Dpostgres_host=localhost -Dpostgres_port=5432 -Dpostgres_user=tasman_tester -Dpostgres_password=tasman_tester -Dpostgres_database=tasman_test"
diff --git a/README.md b/README.md
index 3ca24c5..9648d38 100644
--- a/README.md
+++ b/README.md
@@ -5,41 +5,24 @@ See also the [CHANGELOG](CHANGELOG.md).
 
 ## Build
 
-### Build the API
-
-    cd TASMAN-core
-    mvn install
-
-#### WARNING: test
-Test suite for the TASMAN-core assumes some hardcoded values. If they
-fail simply put an _@Ignore_ in front on the test class.
-
-### Build the Web application
-
-    cd TASMAN-webapp
-
-Edit configuration properties file (`src/main/resources/webapp.properties`):
-
-    ucd_service_url=<URL for the UCD REST web service>
-    config_file_path=<location where the web app will store the generated XML configuration>
-
-IA2 UCD service is at http://ia2-vo.oats.inaf.it:8080/ucd/
-
-If the UCD web service is unreachable the web app will work anyway, but without the UCD search functionality.
-
-Then build the web application:
-
-* GlassFish war package (default):
-
-        mvn install
-
-* Tomcat war package:
-
-        mvn -P Tomcat install
+1. Create a `config.properties` file (copy it from `config.properties.example`). In this file it is specified:
+    * **ucd_service_url**: the URL for the UCD REST web service.
+        * IA2 UCD service is at http://ia2-vo.oats.inaf.it/ucd/
+        * if the UCD web service is unreachable the web app will work anyway, but without the UCD search functionality.
+    * **config_file_path**: the location where the web app will store the generated XML configuration (the location needs to be writable by the application server in which TASMAN will run).
+
+2. `chmod +x build.sh`
+3. `./build.sh <command>`, commands are:
+    * **core** build only TASMAN core
+    * **test**: run tests; you need to create a `test.properties` file containing a configuration for connecting to a MySQL and a Postgres test database
+    * **glassfish**: build GlassFish war package
+    * **tomcat**: build Tomcat war package (using config.properties file)
+    * **embedded**: build embedded package (to be run _locally!_)
+    * **installer**: build install script (produce self-extracting install.sh script)
 
 ## Supported application servers
 
-The web app was tested with:
+The web app has been tested with:
 
 * GlassFish 4.1
 * Tomcat 8.0.33
@@ -51,9 +34,8 @@ Build requires _Ucidy_ and _Unity_ that are not available at central
 maven repo. You should have them installed in a local maven repo.
 
 To do this: download the jar files listed in the following
-credits section and runn a couple of `mvn install:install-file`
-commands based upond the dependencies description in the _TASMAN-webapp_
-_pom.xml_ file.
+credits section and run a couple of `mvn install:install-file`
+commands based upond the dependencies description in the _TASMAN-webapp_ _pom.xml_ file.
 
 ## Credits
 
diff --git a/TASMAN-bom/pom.xml b/TASMAN-bom/pom.xml
new file mode 100644
index 0000000..7e85167
--- /dev/null
+++ b/TASMAN-bom/pom.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    
+    <groupId>it.inaf.ia2.tsm</groupId>
+    <artifactId>tasman-bom</artifactId>
+    <version>1.3.2</version>
+    
+    <packaging>pom</packaging>
+    
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.compiler.source>1.7</maven.compiler.source>
+        <maven.compiler.target>1.7</maven.compiler.target>
+        <netbeans.hint.license>inaf-license-netbeans</netbeans.hint.license>
+        <maven.test.skip>true</maven.test.skip>
+    </properties>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>1.7.21</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.10</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+    
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <version>2.10.4</version>
+                <configuration>
+                    <show>public</show>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.20</version>
+                <configuration>
+                    <trimStackTrace>false</trimStackTrace>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file
diff --git a/TASMAN-core/pom.xml b/TASMAN-core/pom.xml
index bc78d63..23781de 100644
--- a/TASMAN-core/pom.xml
+++ b/TASMAN-core/pom.xml
@@ -1,17 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
-    <groupId>it.inaf.ia2.tap</groupId>
+    
+    <parent>
+        <groupId>it.inaf.ia2.tsm</groupId>
+        <artifactId>tasman-bom</artifactId>
+        <version>1.3.2</version>
+    </parent>
+    
     <artifactId>tasman-core</artifactId>
-    <version>1.3.2</version>
     <packaging>jar</packaging>
-    <name>tasman-core</name>
-    <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <maven.compiler.source>1.7</maven.compiler.source>
-        <maven.compiler.target>1.7</maven.compiler.target>
-        <netbeans.hint.license>inaf-license-netbeans</netbeans.hint.license>
-    </properties>
+    
     <dependencies>
         <dependency>
             <groupId>org.apache.tomcat</groupId>
@@ -31,36 +30,22 @@
             <version>9.3-1104-jdbc41</version>
             <scope>runtime</scope>
         </dependency>
-        <dependency> 
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <version>1.7.21</version>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.10</version>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-javadoc-plugin</artifactId>
-                <version>2.10.4</version>
-                <configuration>
-                    <show>public</show>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <version>2.20</version>
-                <configuration>
-                    <trimStackTrace>false</trimStackTrace>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
+    
+    <profiles>
+        <profile>
+            <id>test</id>
+            <properties>
+                <maven.test.skip>false</maven.test.skip>
+            </properties>
+            <build>
+                <testResources>
+                    <testResource>
+                        <directory>src/test/resources</directory>
+                        <filtering>true</filtering>
+                    </testResource>
+                </testResources>
+            </build>
+        </profile>
+    </profiles>
 </project>
\ No newline at end of file
diff --git a/TASMAN-core/src/test/java/it/inaf/ia2/tsm/TestAll.java b/TASMAN-core/src/test/java/it/inaf/ia2/tsm/TestAll.java
index d68c4e6..cddb760 100644
--- a/TASMAN-core/src/test/java/it/inaf/ia2/tsm/TestAll.java
+++ b/TASMAN-core/src/test/java/it/inaf/ia2/tsm/TestAll.java
@@ -28,6 +28,8 @@ import it.inaf.ia2.tsm.datalayer.Credentials;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.sql.Connection;
@@ -37,6 +39,7 @@ import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
+import java.util.Properties;
 import java.util.Set;
 import org.junit.After;
 import org.junit.AfterClass;
@@ -44,7 +47,6 @@ import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import static org.junit.Assert.*;
-import org.junit.Ignore;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -66,21 +68,29 @@ public class TestAll {
     }
 
     @BeforeClass
-    public static void setUpClass() throws SQLException {
+    public static void setUpClass() throws SQLException, IOException {
+
+        Properties props = new Properties();
+        try (InputStream in = TestAll.class.getClassLoader().getResourceAsStream("test.properties")) {
+            props.load(in);
+        }
 
         dbWrappers = new ArrayList<>();
 
         // MYSQL
         Credentials mysqlCredentials = new Credentials(DatabaseType.MYSQL);
-        mysqlCredentials.setHostname("localhost");
-        mysqlCredentials.setUsername("root");
-        mysqlCredentials.setPassword("root");
+        mysqlCredentials.setHostname(props.getProperty("mysql_host"));
+        mysqlCredentials.setPort(Integer.parseInt(props.getProperty("mysql_port")));
+        mysqlCredentials.setUsername(props.getProperty("mysql_user"));
+        mysqlCredentials.setPassword(props.getProperty("mysql_password"));
 
         // POSTGRES
         Credentials postgresCredentials = new Credentials(DatabaseType.POSTGRES);
-        postgresCredentials.setHostname("localhost");
-        postgresCredentials.setUsername("postgres");
-        postgresCredentials.setPassword("pippo");
+        postgresCredentials.setHostname(props.getProperty("postgres_host"));
+        postgresCredentials.setPort(Integer.parseInt(props.getProperty("postgres_port")));
+        postgresCredentials.setUsername(props.getProperty("postgres_user"));
+        postgresCredentials.setPassword(props.getProperty("postgres_password"));
+        postgresCredentials.setDatabase(props.getProperty("postgres_database"));
 
         DBWrapper dbWrapper = new DBWrapper(mysqlCredentials);
         dbWrapper.testConnections();
diff --git a/TASMAN-embedded/pom.xml b/TASMAN-embedded/pom.xml
index ce0eb8b..dc688c7 100644
--- a/TASMAN-embedded/pom.xml
+++ b/TASMAN-embedded/pom.xml
@@ -2,15 +2,16 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
     
-    <groupId>it.inaf.ia2.tap</groupId>
+    <parent>
+        <groupId>it.inaf.ia2.tsm</groupId>
+        <artifactId>tasman-bom</artifactId>
+        <version>1.3.2</version>
+    </parent>
+    
     <artifactId>tasman-embedded</artifactId>
-    <version>1.2.0</version>
     <packaging>jar</packaging>
     
     <properties>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <maven.compiler.source>1.7</maven.compiler.source>
-        <maven.compiler.target>1.7</maven.compiler.target>
         <jetty.version>9.4.6.v20170531</jetty.version>
     </properties>
     
@@ -36,6 +37,12 @@
     </dependencies>
     
     <build>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+            </resource>
+        </resources>
         <plugins>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
diff --git a/TASMAN-embedded/src/main/resources/app.properties b/TASMAN-embedded/src/main/resources/app.properties
index 086a164..aa8df7e 100644
--- a/TASMAN-embedded/src/main/resources/app.properties
+++ b/TASMAN-embedded/src/main/resources/app.properties
@@ -1,2 +1,2 @@
-warFilePath=/home/sonia/git/TASMAN/TASMAN-webapp/target/tasman-webapp-1.3.2.war
+warFilePath=${war_file_path}
 defaultPort=8080
\ No newline at end of file
diff --git a/TASMAN-webapp/pom.xml b/TASMAN-webapp/pom.xml
index 1fdfc17..06cbf40 100644
--- a/TASMAN-webapp/pom.xml
+++ b/TASMAN-webapp/pom.xml
@@ -2,17 +2,17 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
-    <groupId>it.inaf.ia2.tap</groupId>
+    <parent>
+        <groupId>it.inaf.ia2.tsm</groupId>
+        <artifactId>tasman-bom</artifactId>
+        <version>1.3.2</version>
+    </parent>
+    
     <artifactId>tasman-webapp</artifactId>
-    <version>1.3.2</version>
     <packaging>war</packaging>
 
-    <name>tasman-webapp</name>
-
     <properties>
         <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
-        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-        <netbeans.hint.license>inaf-license-netbeans</netbeans.hint.license>
         <jersey.version>2.23.2</jersey.version>
         <deltaspike.version>1.7.2</deltaspike.version>
         <enable.weld.config.start></enable.weld.config.start>
@@ -128,9 +128,9 @@
     
     <dependencies>
         <dependency>
-            <groupId>it.inaf.ia2.tap</groupId>
+            <groupId>${project.groupId}</groupId>
             <artifactId>tasman-core</artifactId>
-            <version>1.3.2</version>
+            <version>${project.version}</version>
         </dependency>
         <dependency>
             <groupId>ari.ucidy</groupId>
@@ -155,17 +155,6 @@
             <type>jar</type>
             <scope>runtime</scope>
         </dependency>
-        <dependency> 
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-log4j12</artifactId>
-            <version>1.7.21</version>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <version>4.10</version>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>org.apache.deltaspike.modules</groupId>
             <artifactId>deltaspike-jsf-module-impl</artifactId>
@@ -228,6 +217,7 @@
                 <filtering>true</filtering>
                 <includes>
                     <include>**/version.txt</include>
+                    <include>**/webapp.properties</include>
                 </includes>
             </resource>
             <!-- Include all other files without filtering them -->
@@ -236,6 +226,7 @@
                 <filtering>false</filtering>
                 <excludes>
                     <exclude>**/version.txt</exclude>
+                    <exclude>**/webapp.properties</exclude>
                 </excludes>
             </resource>
         </resources>
@@ -245,8 +236,8 @@
                 <artifactId>maven-compiler-plugin</artifactId>
                 <version>3.1</version>
                 <configuration>
-                    <source>1.7</source>
-                    <target>1.7</target>
+                    <source>${maven.compiler.source}</source>
+                    <target>${maven.compiler.target}</target>
                     <compilerArguments>
                         <endorseddirs>${endorsed.dir}</endorseddirs>
                     </compilerArguments>
diff --git a/TASMAN-webapp/src/main/resources/webapp.properties b/TASMAN-webapp/src/main/resources/webapp.properties
index bb985de..50de92b 100644
--- a/TASMAN-webapp/src/main/resources/webapp.properties
+++ b/TASMAN-webapp/src/main/resources/webapp.properties
@@ -1,2 +1,4 @@
-ucd_service_url=http://ia2-vo.oats.inaf.it/ucd/
-config_directory=/home/sonia/.tasman
\ No newline at end of file
+# URL for the UCD REST web service
+ucd_service_url=${ucd_service_url}
+# location where the web app will store the generated XML configuration
+config_directory=${config_directory}
\ No newline at end of file
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..2333fab
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,182 @@
+#!/bin/bash
+
+config_file="config.properties"
+test_config_file="test.properties"
+
+if [ ! -f "$config_file" ]; then
+  echo "$config_file doesn't exist!"
+  exit 1
+fi
+
+# Append to a command a list of environment variables defined into a file
+function add_properties {
+  command=$1
+  properties_file=$2
+
+  while read line
+  do
+    if [[ ! -z "$line" ]] && [[ ! "$line" =~ ^\# ]]; then
+      command="$command -D$line"
+    fi
+  done <<< "$(cat ../$properties_file)"
+
+  echo $command
+}
+
+function build_core {
+  cd TASMAN-core
+  mvn -q clean install
+  if [ "$?" -ne 0 ]; then
+    echo "[ERROR] Error in ${FUNCNAME[0]}"
+    exit 1
+  fi
+  echo "TASMAN-core built"
+  cd ..
+}
+
+function test_core {
+  cd TASMAN-core
+  $(add_properties "mvn clean install -P test" $test_config_file)
+  if [ "$?" -ne 0 ]; then
+    echo "[ERROR] Error in ${FUNCNAME[0]}"
+    exit 1
+  fi
+  cd ..
+}
+
+function build_web_glassfish {
+  build_core
+
+  # build webapp
+  cd TASMAN-webapp
+  $(add_properties "mvn -q clean install" $config_file)
+  if [ "$?" -ne 0 ]; then
+    echo "[ERROR] Error in ${FUNCNAME[0]}"
+    exit 1
+  fi
+  echo "TASMAN-webapp built"
+  cd ..
+}
+
+function build_web_tomcat {
+  build_core
+
+  # build webapp
+  cd TASMAN-webapp
+  $(add_properties "mvn -q clean install -P ServletContainer" $config_file)
+  if [ "$?" -ne 0 ]; then
+    echo "[ERROR] Error in ${FUNCNAME[0]}"
+    exit 1
+  fi
+  echo "TASMAN-webapp built"
+  cd ..
+}
+
+function build_web_embedded {
+  build_core
+
+  # build webapp
+  cd TASMAN-webapp
+  $(add_properties "mvn -q clean install -P ServletContainer,Jetty" $config_file)
+  if [ "$?" -ne 0 ]; then
+    echo "[ERROR] Error in ${FUNCNAME[0]}"
+    exit 1
+  fi
+  echo "TASMAN-webapp built"
+  cd ..
+
+  # build embedded
+  cd TASMAN-embedded
+  war_file_path=`dirname ${PWD}`/TASMAN-webapp/target/tasman-webapp-*.war
+  war_file_path=`ls $war_file_path`
+  mvn clean -q install -Dwar_file_path=$war_file_path
+  if [ "$?" -ne 0 ]; then
+    echo "[ERROR] Error in ${FUNCNAME[0]}"
+    exit 1
+  fi
+  echo "TASMAN-embedded built"
+  cd ..
+}
+
+function build_installer_package {
+  build_core
+
+  # build webapp
+  cd TASMAN-webapp
+  mvn -q clean install -P ServletContainer,Jetty
+  if [ "$?" -ne 0 ]; then
+    echo "[ERROR] Error in ${FUNCNAME[0]}"
+    exit 1
+  fi
+  echo "TASMAN-webapp built"
+  cd ..
+
+  # build embedded
+  cd TASMAN-embedded
+  mvn -q clean install
+  if [ "$?" -ne 0 ]; then
+    echo "[ERROR] Error in ${FUNCNAME[0]}"
+    exit 1
+  fi
+  echo "TASMAN-embedded built"
+  cd ..
+
+  # copy TASMAN files
+  cp TASMAN-webapp/target/tasman-webapp-*.war .
+  cp TASMAN-embedded/target/tasman-embedded.jar .
+  mv tasman-webapp-*.war tasman-webapp.war
+  # create tar for self-extracting installer
+  tar cfz tasman.tar.gz tasman-webapp.war tasman-embedded.jar
+  rm tasman-webapp.war
+  rm tasman-embedded.jar
+  cp install_template.sh install.sh
+  cat tasman.tar.gz >> install.sh
+  rm tasman.tar.gz
+  echo "TASMAN install.sh built"
+}
+
+function print_usage {
+  echo "USAGE:"
+  echo "   $0 command"
+  echo " "
+  echo "COMMANDS:"
+  echo "   core           build only TASMAN core"
+  echo "   test           run tests (using test.properties file)"
+  echo "   glassfish      build GlassFish war package (using config.properties file)"
+  echo "   tomcat         build Tomcat war package (using config.properties file)"
+  echo "   embedded       build embedded package (using config.properties file)"
+  echo "   installer      build install script (produces install.sh as output)"
+  exit 0
+}
+
+if [ "$#" -ne 1 ]; then
+  print_usage
+fi
+
+case "$1" in
+"core")
+  build_core
+  ;;
+"test")
+  if [ ! -f "$test_config_file" ]; then
+    echo "$test_config_file doesn't exist!"
+    exit 1
+  fi
+  test_core
+  ;;
+"glassfish")
+  build_web_glassfish
+  ;;
+"tomcat")
+  build_web_tomcat
+  ;;
+"embedded")
+  build_web_embedded
+  ;;
+"installer")
+  build_installer_package
+  ;;
+*)
+  print_usage
+  ;;
+esac
diff --git a/config.properties.example b/config.properties.example
new file mode 100644
index 0000000..1d37d00
--- /dev/null
+++ b/config.properties.example
@@ -0,0 +1,2 @@
+ucd_service_url=http://ia2-vo.oats.inaf.it/ucd/
+config_directory=/home/user/.tasman
\ No newline at end of file
diff --git a/install.sh b/install_template.sh
old mode 100755
new mode 100644
similarity index 88%
rename from install.sh
rename to install_template.sh
index 4135e2d..56dbf95
--- a/install.sh
+++ b/install_template.sh
@@ -12,6 +12,9 @@ echo "#                                          #"
 echo "############################################"
 echo ""
 
+# Credits for the self-extracting part:
+# http://www.linuxjournal.com/node/1005818
+
 echo "Welcome on the TASMAN installer"
 
 # Run as root check
@@ -20,6 +23,33 @@ if [[ "$(id -u)" != "0" ]]; then
     exit 1
 fi
 
+# Tasman installation dir
+echo -e "Specify TASMAN installation directory [/opt/tasman]: \c"
+read install_dir
+if [[ -z "$install_dir" ]]; then
+    install_dir="/opt/tasman"
+fi
+
+# Creating installation directory
+mkdir -p "$install_dir"
+if [ ! $? -eq 0 ]; then
+    echo "Unable to create installation directory $install_dir"
+    exit 1
+fi
+
+# Add final slash to installation dir if it is necessary
+if [[ "$install_dir" != *\/ ]]; then
+   install_dir="$install_dir/"
+fi
+
+# Find __ARCHIVE__ maker, read archive content and decompress it
+ARCHIVE=`awk '/^__ARCHIVE__/ {print NR + 1; exit 0; }' $0`
+tail -n+$ARCHIVE $0 | tar xzv -C ${install_dir}
+if [ ! $? -eq 0 ]; then
+    echo "Unable to extract installation files"
+    exit 1
+fi
+
 # Default port
 echo -e "Specify default port for TASMAN (you can change it runtime) [8080]: \c"
 read default_port
@@ -35,13 +65,6 @@ if [[ "$default_port" -lt "1024" ]]; then
     exit 1
 fi
 
-# Tasman installation dir
-echo -e "Specify TASMAN installation directory [/opt/tasman]: \c"
-read install_dir
-if [[ -z "$install_dir" ]]; then
-    install_dir="/opt/tasman"
-fi
-
 # UCD service URL
 echo -e "Specify UCD service URL [http://ia2-vo.oats.inaf.it/ucd/]: \c"
 read ucd_service_url
@@ -66,22 +89,6 @@ fi
 #    useradd -r tasman
 #fi
 
-# Creating installation directory
-mkdir -p "$install_dir"
-if [ ! $? -eq 0 ]; then
-    echo "Unable to create installation directory $install_dir"
-    exit 1
-fi
-
-# Add final slash to installation dir if it is necessary
-if [[ "$install_dir" != *\/ ]]; then
-   install_dir="$install_dir/"
-fi
-
-# Copying files
-cp data/tasman-embedded.jar "$install_dir"
-cp data/tasman-webapp.war "$install_dir"
-
 cd $install_dir
 
 # Configuring tasman-embedded
@@ -108,7 +115,7 @@ echo "java -jar $install_dir""tasman-embedded.jar \$1" >> $tasman_bin
 chmod +x $tasman_bin
 
 # Creating executable symbolic link
-ln -s $tasman_bin /usr/bin/tasman
+ln -sfn $tasman_bin /usr/bin/tasman
 
 # Setting permissions
 chmod -R 777 $tasman_config_dir
@@ -117,3 +124,8 @@ echo "######################################"
 echo "# TASMAN installation completed! :-) #"
 echo "######################################"
 echo "Notice that $tasman_config_dir has 777 permissions. If you are planning to use TASMAN only with a specific user you may want to restrict permissions on that folder."
+
+# Exit from the script with success (0)
+exit 0
+
+__ARCHIVE__
diff --git a/test.properties.example b/test.properties.example
new file mode 100644
index 0000000..5e0b06c
--- /dev/null
+++ b/test.properties.example
@@ -0,0 +1,12 @@
+# MySQL test database
+mysql_host=localhost
+mysql_port=3306
+mysql_user=
+mysql_password=
+
+# Postgres test database
+postgres_host=localhost
+postgres_port=5432
+postgres_user=
+postgres_password=
+postgres_database=
diff --git a/update_version.sh b/update_version.sh
new file mode 100755
index 0000000..0b9ff46
--- /dev/null
+++ b/update_version.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+# Keep synchronized parent and children versions
+
+if [ "$#" -ne 1 ]; then
+  echo "Usage: $0 <version>"
+  exit
+fi
+
+version=$1
+
+cd TASMAN-bom
+mvn -q versions:set -DnewVersion=$version
+mvn -q clean install
+cd ../TASMAN-core
+mvn -q versions:update-parent -DparentVersion=$version
+cd ../TASMAN-webapp
+mvn -q versions:update-parent -DparentVersion=$version
+cd ../TASMAN-embedded
+mvn -q versions:update-parent -DparentVersion=$version
+
+echo "Done"
-- 
GitLab