diff --git a/pom.xml b/pom.xml
index 2a29d64..292293f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
7.0.64
src/resources
UTF-8
@@ -62,7 +62,7 @@
tar.gz
-
+
@@ -117,7 +117,7 @@
${basedir}/${targetDirectory}/${smartgearsDirectory}
- war
+ jar,war
diff --git a/src/resources/setup.sh b/src/resources/setup.sh
index 95371a3..fa1fa93 100644
--- a/src/resources/setup.sh
+++ b/src/resources/setup.sh
@@ -19,18 +19,66 @@ export CATALINA_PID=${SMARTGEAR_ROOT}/${TOMCAT_PID_FILENAME}
export CATALINA_HOME=${SMARTGEAR_ROOT}/${TOMCAT_DST_FOLDER}
export BUNDLE_HOME=${SMARTGEAR_ROOT}"
-
function showhelp {
- echo -e "\nUsage: setup.sh [-f |-h] \n"
- echo " f = Really run the setup. By default it will be a dry-run"
- echo -e " h = shows this help.\n"
+ echo -e "\nUsage: setup.sh [-n ] [-f | -h] \n"
+ echo " -n = The hostname to set in container.xml"
+ 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
- f) force=true;;
+ n) HOST=$OPTARG;;
+ f) force=true;;
h) showhelp
-exit 0 ;;
+ exit 0 ;;
\?) echo -e "\nERROR:invalid option: -$OPTARG";
showhelp;
echo -e "\naborting.\n"
@@ -69,6 +117,9 @@ if [ $force ]; then
./install -s tomcat -g ${GHN_HOME}
+ hostname
+ change_line "" "\t$HOST" ${CONTAINER_XML}
+
echo -e "\n\n\n"
echo "Just few steps to do to reach the goal:"
@@ -78,9 +129,9 @@ if [ $force ]; then
echo -e "\n\n"
echo "Then:"
else
- echo "We are showing the list of steps to setup SmartGear."
- echo "Use -h to see the script help."
- echo "Use -f to allow this script to perform automatically the required steps to setup Smartgear"
+ showhelp
+
+ echo "Here it is the list of steps to setup SmartGear."
echo ""
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 -e "\n\n"
+
echo "Then:"
+ echo "- Modify ${CONTAINER_XML} with your hostname"
fi
-
-echo "- Modify ${CONTAINER_XML} with your hostname"
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 Stop the container from ${BUNDLE_HOME} directory using the command ./${STOP_SCRIPT}"
echo ""
-echo "PLEASE NOTE:
-By default Tomcat start on 8080 port. If you want to change this port REMEMBER to modify ${CONTAINER_XML} consistently"
-
-
-
+echo "PLEASE NOTE:"
+echo "By default Tomcat start on 8080 port. If you want to change this port REMEMBER to modify ${CONTAINER_XML} consistently"
\ No newline at end of file