|
| 1 | +#! /bin/bash |
| 2 | +# |
| 3 | +# This file is part of the Squashtest platform. |
| 4 | +# Copyright (C) 2010 - 2012 Henix, henix.fr |
| 5 | +# |
| 6 | +# See the NOTICE file distributed with this work for additional |
| 7 | +# information regarding copyright ownership. |
| 8 | +# |
| 9 | +# This is free software: you can redistribute it and/or modify |
| 10 | +# it under the terms of the GNU Lesser General Public License as published by |
| 11 | +# the Free Software Foundation, either version 3 of the License, or |
| 12 | +# (at your option) any later version. |
| 13 | +# |
| 14 | +# this software is distributed in the hope that it will be useful, |
| 15 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | +# GNU Lesser General Public License for more details. |
| 18 | +# |
| 19 | +# You should have received a copy of the GNU Lesser General Public License |
| 20 | +# along with this software. If not, see <http://www.gnu.org/licenses/>. |
| 21 | +# |
| 22 | + |
| 23 | + |
| 24 | +#That script will : |
| 25 | +#- check that the java environnement exists, |
| 26 | +#- the version is adequate, |
| 27 | +#- will run the application |
| 28 | + |
| 29 | + |
| 30 | +# Default variables |
| 31 | +JAR_NAME="org.apache.felix.main-4.2.1.jar" # Java main library |
| 32 | +HTTP_PORT=8080 # Port for HTTP connector (default 8080; disable with -1) |
| 33 | +# Directory variables |
| 34 | +TMP_DIR=../tmp # Jetty tmp and work directory |
| 35 | +BUNDLES_DIR=../bundles # Bundles directory |
| 36 | +CACHE_DIR=.. # Cache directory |
| 37 | +CONF_DIR=../conf # Configurations directory |
| 38 | +LOG_DIR=../logs # Log directory |
| 39 | +JETTY_HOME=../jettyhome # Jetty home directory |
| 40 | +LUCENE_DIR=../luceneindexes # Lucene indexes directory |
| 41 | +PLUGINS_DIR=../plugins # Plugins directory |
| 42 | +# DataBase parameters |
| 43 | +DB_URL=${DB_URL:-"jdbc:h2:../data/squash-tm"} # DataBase URL |
| 44 | +DB_DRIVER=${DB_DRIVER:-"org.h2.Driver"} # DataBase driver |
| 45 | +DB_USERNAME=${DB_USERNAME:-"sa"} # DataBase username |
| 46 | +DB_PASSWORD=${DB_PASSWORD:-"sa"} # DataBase password |
| 47 | +DB_DIALECT=${DB_DIALECT:-"org.hibernate.dialect.H2Dialect"} # DataBase dialect |
| 48 | +## Do not configure a third digit here |
| 49 | +REQUIRED_VERSION=1.6 |
| 50 | +# Extra Java args |
| 51 | +JAVA_ARGS=${JAVA_ARGS:-"-Xms128m -Xmx512m -XX:MaxPermSize=192m -server"} |
| 52 | + |
| 53 | + |
| 54 | +# Tests if java exists |
| 55 | +echo -n "$0 : checking java environment... "; |
| 56 | + |
| 57 | +java_exists=`java -version 2>&1`; |
| 58 | + |
| 59 | +if [ $? -eq 127 ] |
| 60 | +then |
| 61 | + echo; |
| 62 | + echo "$0 : Error : java not found. Please ensure that \$JAVA_HOME points to the correct directory."; |
| 63 | + echo "If \$JAVA_HOME is correctly set, try exporting that variable and run that script again. Eg : "; |
| 64 | + echo "\$ export \$JAVA_HOME"; |
| 65 | + echo "\$ ./$0"; |
| 66 | + exit -1; |
| 67 | +fi |
| 68 | + |
| 69 | +echo "done"; |
| 70 | + |
| 71 | +# Create logs and tmp directories if necessary |
| 72 | +if [ ! -e "$LOG_DIR" ]; then |
| 73 | + mkdir $LOG_DIR |
| 74 | +fi |
| 75 | + |
| 76 | +if [ ! -e "$TMP_DIR" ]; then |
| 77 | + mkdir $TMP_DIR |
| 78 | +fi |
| 79 | + |
| 80 | +# Tests if the version is high enough |
| 81 | +echo -n "checking version... "; |
| 82 | + |
| 83 | +NUMERIC_REQUIRED_VERSION=`echo $REQUIRED_VERSION |sed 's/\./0/g'`; |
| 84 | +java_version=`echo $java_exists | grep version |cut -d " " -f 3 |sed 's/\"//g' | cut -d "." -f 1,2 | sed 's/\./0/g'`; |
| 85 | + |
| 86 | +if [ $java_version -lt $NUMERIC_REQUIRED_VERSION ] |
| 87 | +then |
| 88 | + echo; |
| 89 | + echo "$0 : Error : your JRE does not meet the requirements. Please install a new JRE, required version ${REQUIRED_VERSION}."; |
| 90 | + exit -2; |
| 91 | +fi |
| 92 | + |
| 93 | +echo "done"; |
| 94 | + |
| 95 | + |
| 96 | +# Let's go ! |
| 97 | +echo "$0 : starting Felix... "; |
| 98 | + |
| 99 | +export _JAVA_OPTIONS="-Ddb.driver=${DB_DRIVER} -Ddb.url=${DB_URL} -Ddb.username=${DB_USERNAME} -Ddb.password=${DB_PASSWORD} -Ddb.dialect=${DB_DIALECT} -Duser.language=en" |
| 100 | +DAEMON_ARGS="${JAVA_ARGS} -Dbundles.dir=${BUNDLES_DIR} -Dcache.dir=${CACHE_DIR} -Dconf.dir=${CONF_DIR} -Dlog.dir=${LOG_DIR} -Dplugins.dir=${PLUGINS_DIR} -Djetty.logs=${LOG_DIR} -Dbundles.configuration.location=${CONF_DIR} -Dfelix.config.properties=file:${CONF_DIR}/felix.config.properties -Dfelix.system.properties=file:${CONF_DIR}/felix.system.properties -Djetty.port=${HTTP_PORT} -Djetty.home=${JETTY_HOME} -Dlucene.dir=${LUCENE_DIR} -Djava.io.tmpdir=${TMP_DIR} -Dlog4j.configuration=file:./conf/log4j.properties -jar ${JAR_NAME}" |
| 101 | + |
| 102 | +find ${TMP_DIR} -delete > /dev/null 2>&1 |
| 103 | + |
| 104 | +exec java ${DAEMON_ARGS} |
| 105 | + |
0 commit comments