Strabon

view scripts/redeploy @ 528:ee19ee42b46f

fix in redeploy script
author George Garbis <ggarbis@di.uoa.gr>
date Mon Jul 30 22:13:58 2012 +0300 (2012-07-30)
parents eebc02275912
children b95784675cc7
line source
1 #! /bin/bash
3 # this command
4 CMD="$(basename ${0})"
6 function print_help() {
7 echo "Usage ${CMD} [OPTIONS]"
8 echo
9 echo "Redeploy endpoint on tomcat"
10 echo
11 echo "OPTIONS"
12 echo " -w, --webapps: path to tomcat webapps folder (default: /var/lib/tomcat7/webapss)"
13 echo " -t, --tomcat: the version of the installed tomcat (default: tomcat7)"
14 echo " -c, --catalina: value of CATALINA_BASE (use only if tomcat works in standalone version)"
15 echo " when -c is specified -t must not be specified and vice versa"
16 echo " -p, --postgres: the version of the installed tomcat (default: postgresql)"
17 echo " -e, --endpoint: the name of the finally deployed war (default: endpoint)"
18 echo " -b: not only redeploy the war but also rebuild it (mvn clean package)"
19 echo " -o: mvn will build the new endpoint working in offline mode"
20 echo " -h, --help: print this message"
21 }
24 # Default values of arguments
25 webapps="/var/lib/tomcat7/webapps"
26 tomcat=""
27 catalina=""
28 postgres="postgresql"
29 endpoint="endpoint"
31 # Parse arguments
32 temp=`getopt -o hbow:t:p:e:c: --long help,webapps:,tomcat:,postgres:,endpoint:,catalina-base -n 'redeploy' -- "$@"`
33 eval set -- "$temp"
34 while true; do
35 case "$1" in
36 -w|--webapps)
37 webapps=`echo $2 | sed 's#\/$##g'`; shift 2;;
38 -t|--tomcat)
39 tomcat=$2; shift 2;;
40 -p|--postgres)
41 postgres=$2; shift 2;;
42 -e|--endpoint)
43 endpoint=$2; shift 2;;
44 -b)
45 build=true; shift;;
46 -o)
47 offline=true; shift;;
48 -c|--catalina-base)
49 catalina=`echo $2 | sed 's#\/$##g'`; shift 2;;
50 -h|--help)
51 print_help; exit 0;;
52 --)
53 shift; break;;
54 *)
55 echo "Interanl error!"; exit 1;;
56 esac
57 done
59 if [ "${catalina}" != "" -a "${tomcat}" != "" ]; then
60 echo "You cannot specify both catalina and tomcat options at the same time!"
61 exit -1
62 elif [ "${catalina}" == "" -a "${tomcat}" == "" ]; then
63 tomcat="tomcat7"
64 fi
66 # Build package
67 if [ $build ]; then
68 if [ $offline ]; then
69 mvn -o clean package
70 else
71 mvn clean package
72 fi
73 fi
75 if [ ! -f endpoint/target/strabon-endpoint-*.war ]; then
76 echo "File endpoint/target/strabon-endpoint-*.war cannot be found."
77 echo "This script must be executed in Strabon folder"
78 exit -1
79 fi
81 if [ "`ls ${webapps}|grep war|grep -v ${endpoint}.war`" != "" ];then
82 echo "WARNING: there are other war applications in ${webapps}"
83 fi
85 #echo "Stand alone: ${tomcatStandalone}"
86 ## Redeploy
87 #test -e ${tomcatStandalone}
88 #cond=$?
89 #if [ ${cond} -eq 1 ]; then
90 if [ "${catalina}" != "" ]; then
91 ${catalina}/bin/shutdown.sh &&
92 sudo service ${postgres} stop &&
93 sudo rm -f ${webapps}/${endpoint}.war &&
94 sudo rm -rf ${webapps}/${endpoint} &&
95 sudo cp endpoint/target/strabon-endpoint-*.war ${webapps}/${endpoint}.war &&
96 sudo service ${postgres} start &&
97 ${catalina}/bin/startup.sh start
98 else
99 sudo service ${tomcat} stop &&
100 sudo service ${postgres} stop &&
101 sudo rm -f ${webapps}/${endpoint}.war &&
102 sudo rm -rf ${webapps}/${endpoint} &&
103 sudo cp endpoint/target/strabon-endpoint-*.war ${webapps}/${endpoint}.war &&
104 sudo service ${postgres} start &&
105 sudo service ${tomcat} start
106 fi