refs #77: Improve setup for smartgears-distribution-bundle

https://support.d4science.org/issues/77
Added the possibility to specify hostname as paramenter which is filled in container.xml. Furthermore the hostname is requested during the setup process.

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/distributions/smartgears-distribution-bundle@122168 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-01-08 14:18:41 +00:00
parent c5bcb3d4e6
commit e31975b09c
2 changed files with 68 additions and 20 deletions

View File

@ -22,7 +22,7 @@
<tomcat.version>7.0.64</tomcat.version> <tomcat.version>7.0.64</tomcat.version>
<!-- This property MUST be passed as argument from command line <!-- This property MUST be passed as argument from command line
i.e. mvn compile -Dsmartgears-distribution.version=1.2.5-SNAPSHOT i.e. mvn compile -Dsmartgears-distribution.version=1.2.5-SNAPSHOT
<smartgears-distribution.version>1.2.5-SNAPSHOT</smartgears-distribution.version> <smartgears-distribution.version>1.2.6-SNAPSHOT</smartgears-distribution.version>
--> -->
<resourcesDirectory>src/resources</resourcesDirectory> <resourcesDirectory>src/resources</resourcesDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -62,7 +62,7 @@
<type>tar.gz</type> <type>tar.gz</type>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
@ -117,7 +117,7 @@
</goals> </goals>
<configuration> <configuration>
<outputDirectory>${basedir}/${targetDirectory}/${smartgearsDirectory}</outputDirectory> <outputDirectory>${basedir}/${targetDirectory}/${smartgearsDirectory}</outputDirectory>
<excludeTypes>war</excludeTypes> <excludeTypes>jar,war</excludeTypes>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>

View File

@ -19,18 +19,66 @@ export CATALINA_PID=${SMARTGEAR_ROOT}/${TOMCAT_PID_FILENAME}
export CATALINA_HOME=${SMARTGEAR_ROOT}/${TOMCAT_DST_FOLDER} export CATALINA_HOME=${SMARTGEAR_ROOT}/${TOMCAT_DST_FOLDER}
export BUNDLE_HOME=${SMARTGEAR_ROOT}" export BUNDLE_HOME=${SMARTGEAR_ROOT}"
function showhelp { function showhelp {
echo -e "\nUsage: setup.sh [-f |-h] \n" echo -e "\nUsage: setup.sh [-n <hostname>] [-f | -h] \n"
echo " f = Really run the setup. By default it will be a dry-run" echo " -n <hostname> = The hostname to set in container.xml"
echo -e " h = shows this help.\n" echo " -f = Really run the setup. By default it will be a dry-run"
echo -e " -h = shows this help.\n"
} }
while getopts ":d:fh" opt; do function hostname {
local DOMAIN=$(/bin/domainname)
local HOSTNAME=$(/bin/hostname)
if [ -z "$HOST" ]; then
HOST=${HOSTNAME}.${DOMAIN}
fi
local HOST_OK=false
while [ "$HOST_OK" = false ]
do
echo "Is ${HOST} correct?"
select yn in "Yes" "No";
do
case $yn in
Yes )
ok=true
HOST_OK=true;
break;;
No )
ok=false
break;;
esac
done
if [ "$ok" = false ]; then
read -p "Please input the hostname [followed by ENTER]: " HOST
fi
done
}
function escape_slashes {
sed 's/\//\\\//g'
}
function change_line {
local OLD_LINE_PATTERN=$1; shift
local NEW_LINE=$1; shift
local FILE=$1
local NEW=$(echo "${NEW_LINE}" | escape_slashes)
sed -i '/'"${OLD_LINE_PATTERN}"'/s/.*/'"${NEW}"'/' "${FILE}"
}
while getopts ":n:fh" opt; do
case $opt in case $opt in
f) force=true;; n) HOST=$OPTARG;;
f) force=true;;
h) showhelp h) showhelp
exit 0 ;; exit 0 ;;
\?) echo -e "\nERROR:invalid option: -$OPTARG"; \?) echo -e "\nERROR:invalid option: -$OPTARG";
showhelp; showhelp;
echo -e "\naborting.\n" echo -e "\naborting.\n"
@ -69,6 +117,9 @@ if [ $force ]; then
./install -s tomcat -g ${GHN_HOME} ./install -s tomcat -g ${GHN_HOME}
hostname
change_line "<hostname>" "\t<hostname>$HOST</hostname>" ${CONTAINER_XML}
echo -e "\n\n\n" echo -e "\n\n\n"
echo "Just few steps to do to reach the goal:" echo "Just few steps to do to reach the goal:"
@ -78,9 +129,9 @@ if [ $force ]; then
echo -e "\n\n" echo -e "\n\n"
echo "Then:" echo "Then:"
else else
echo "We are showing the list of steps to setup SmartGear." showhelp
echo "Use -h to see the script help."
echo "Use -f to allow this script to perform automatically the required steps to setup Smartgear" echo "Here it is the list of steps to setup SmartGear."
echo "" echo ""
echo "Create tomcat symlink with the following command:" echo "Create tomcat symlink with the following command:"
@ -110,20 +161,17 @@ else
echo "The previous steps can be made by launching this script with -f option" echo "The previous steps can be made by launching this script with -f option"
echo -e "\n\n" echo -e "\n\n"
echo "Then:" echo "Then:"
echo "- Modify ${CONTAINER_XML} with your hostname"
fi fi
echo "- Modify ${CONTAINER_XML} with your hostname"
echo "- Modify ${CONTAINER_XML} startup infrastructure and vres" echo "- Modify ${CONTAINER_XML} startup infrastructure and vres"
echo "- You can Start the container from ${BUNDLE_HOME} directory using the command ./${STARTUP_SCRIPT}" echo "- You can Start the container from ${BUNDLE_HOME} directory using the command ./${STARTUP_SCRIPT}"
echo "- You can Stop the container from ${BUNDLE_HOME} directory using the command ./${STOP_SCRIPT}" echo "- You can Stop the container from ${BUNDLE_HOME} directory using the command ./${STOP_SCRIPT}"
echo "" echo ""
echo "PLEASE NOTE: echo "PLEASE NOTE:"
By default Tomcat start on 8080 port. If you want to change this port REMEMBER to modify ${CONTAINER_XML} consistently" echo "By default Tomcat start on 8080 port. If you want to change this port REMEMBER to modify ${CONTAINER_XML} consistently"