Strabon

view scripts/redeploy @ 974:f658d2b036d9

Checked if the results of the query are the right.
author Panayiotis Smeros <psmeros@di.uoa.gr>
date Wed Apr 03 20:35:45 2013 +0300 (2013-04-03)
parents ee19ee42b46f
children
line source
1 #! /bin/bash
3 #
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 #
8 # Copyright (C) 2010, 2011, 2012, Pyravlos Team
9 #
10 # http://www.strabon.di.uoa.gr/
11 #
13 # this command
14 CMD="$(basename ${0})"
16 function print_help() {
17 echo "Usage ${CMD} [OPTIONS]"
18 echo
19 echo "Redeploy endpoint on tomcat"
20 echo
21 echo "OPTIONS"
22 echo " -w, --webapps: path to tomcat webapps folder (default: /var/lib/tomcat7/webapss)"
23 echo " -t, --tomcat: the version of the installed tomcat (default: tomcat7)"
24 echo " -c, --catalina: value of CATALINA_BASE (use only if tomcat works in standalone version)"
25 echo " when -c is specified -t must not be specified and vice versa"
26 echo " -p, --postgres: the version of the installed tomcat (default: postgresql)"
27 echo " -e, --endpoint: the name of the finally deployed war (default: endpoint)"
28 echo " -b: not only redeploy the war but also rebuild it (mvn clean package)"
29 echo " -o: mvn will build the new endpoint working in offline mode"
30 echo " -h, --help: print this message"
31 }
34 # Default values of arguments
35 webapps="/var/lib/tomcat7/webapps"
36 tomcat=""
37 catalina=""
38 postgres="postgresql"
39 endpoint="endpoint"
41 # Parse arguments
42 temp=`getopt -o hbow:t:p:e:c: --long help,webapps:,tomcat:,postgres:,endpoint:,catalina-base -n 'redeploy' -- "$@"`
43 eval set -- "$temp"
44 while true; do
45 case "$1" in
46 -w|--webapps)
47 webapps=`echo $2 | sed 's#\/$##g'`; shift 2;;
48 -t|--tomcat)
49 tomcat=$2; shift 2;;
50 -p|--postgres)
51 postgres=$2; shift 2;;
52 -e|--endpoint)
53 endpoint=$2; shift 2;;
54 -b)
55 build=true; shift;;
56 -o)
57 offline=true; shift;;
58 -c|--catalina-base)
59 catalina=`echo $2 | sed 's#\/$##g'`; shift 2;;
60 -h|--help)
61 print_help; exit 0;;
62 --)
63 shift; break;;
64 *)
65 echo "Interanl error!"; exit 1;;
66 esac
67 done
69 if [ "${catalina}" != "" -a "${tomcat}" != "" ]; then
70 echo "You cannot specify both catalina and tomcat options at the same time!"
71 exit -1
72 elif [ "${catalina}" == "" -a "${tomcat}" == "" ]; then
73 tomcat="tomcat7"
74 fi
76 # Build package
77 if [ $build ]; then
78 if [ $offline ]; then
79 mvn -o clean package
80 else
81 mvn clean package
82 fi
83 fi
85 if [ ! -f endpoint/target/strabon-endpoint-*.war ]; then
86 echo "File endpoint/target/strabon-endpoint-*.war cannot be found."
87 echo "This script must be executed in Strabon folder"
88 exit -1
89 fi
91 if [ "`ls ${webapps}|grep war|grep -v ${endpoint}.war`" != "" ];then
92 echo "WARNING: there are other war applications in ${webapps}"
93 fi
95 #echo "Stand alone: ${tomcatStandalone}"
96 ## Redeploy
97 #test -e ${tomcatStandalone}
98 #cond=$?
99 #if [ ${cond} -eq 1 ]; then
100 if [ "${catalina}" != "" ]; then
101 ${catalina}/bin/shutdown.sh &&
102 sudo service ${postgres} stop &&
103 sudo rm -f ${webapps}/${endpoint}.war &&
104 sudo rm -rf ${webapps}/${endpoint} &&
105 sudo cp endpoint/target/strabon-endpoint-*.war ${webapps}/${endpoint}.war &&
106 sudo service ${postgres} start &&
107 ${catalina}/bin/startup.sh start
108 else
109 sudo service ${tomcat} stop &&
110 sudo service ${postgres} stop &&
111 sudo rm -f ${webapps}/${endpoint}.war &&
112 sudo rm -rf ${webapps}/${endpoint} &&
113 sudo cp endpoint/target/strabon-endpoint-*.war ${webapps}/${endpoint}.war &&
114 sudo service ${postgres} start &&
115 sudo service ${tomcat} start
116 fi