-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_and_deploy_to_local_glasshfish.sh
109 lines (93 loc) · 3.26 KB
/
build_and_deploy_to_local_glasshfish.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
#
#
# Copyright
# 2009-2015 Jayway Products AB
# 2016-2018 Föreningen Sambruk
#
# Licensed under AGPL, Version 3.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.gnu.org/licenses/agpl.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
###########
#This script...
#... builds webclient war
#... deploys it to local Glassfish installation
#... changes proxy API url to desired url
#
#Please feel free to improve it!
#
#NB! You need a local Glassfish installation with the default domain started.
###########
## TODO: check if glassfish is running
## TODO: parameterize API url, Glassfish location, version
## TODO: sed - "3rd line after line with proxy class"
## Variables
LOCAL_GLASSFISH=''
APPLICATION_VERSION=''
API_URL=''
CONTEXT_ROOT=webclient
## Usage
usage="usage: $0 [-v VERSION_NAME] [-u API_URL] [-g GLASSFISH_PATH] [-h]
$option -v application version name (e.g. 1.0-SNAPSHOT)
$option -u url to desired api (e.g. http://test-sf.jayway.com/streamflow)
$option -g path to local Glassfish installation (e.g. /Applications/Glassfish/glassfish4)
$option -h prints this help"
while getopts "v:u:g:h" opt
do
case $opt in
v ) APPLICATION_VERSION=$OPTARG ;;
u ) API_URL=$OPTARG ;;
g ) LOCAL_GLASSFISH=$OPTARG ;;
h ) echo "$usage"
exit 0 ;;
\?) echo "$usage"
exit 2 ;;
esac
done
shift $((OPTIND-1))
## Check arguments
if [ -z ${APPLICATION_VERSION} ]; then
echo "You must provide version to build and deploy (VERSION_NAME)"
echo "$usage"
exit 2
fi
if [ -z ${API_URL} ]; then
echo "You must provide url to API that proxy should connect to (API_URL)"
echo "$usage"
exit 2
fi
if [ -z ${LOCAL_GLASSFISH} ]; then
echo "You must provide path to local Glassfish installation (GLASSFISH_PATH)"
echo "$usage"
exit 2
fi
APPLICATION_NAME=streamflow-webclient-${APPLICATION_VERSION}
echo ":::: *** Build and deploy to local glassfish *** ::::"
echo ":::: Using Application version name: ${APPLICATION_VERSION}"
echo ":::: Using API url: ${API_URL}"
echo ":::: Using Glassfish path: ${LOCAL_GLASSFISH}"
## Build application
echo ":::: Step: Build application ::::"
mvn clean install
## Deploy application in local Glassfish
echo ":::: Step: Deploy war file ${APPLICATION_NAME}.war ::::"
${LOCAL_GLASSFISH}/bin/asadmin deploy --force=true --contextroot=${CONTEXT_ROOT} target/${APPLICATION_NAME}.war
## Disable application
echo ":::: Step: Disable application ::::"
${LOCAL_GLASSFISH}/bin/asadmin disable ${APPLICATION_NAME}
## Change proxy API url
echo ":::: Step: Set proxy API url to ${API_URL} ::::"
sed -i '' "s#http://localhost/streamflow#${API_URL}#g" ${LOCAL_GLASSFISH}/glassfish/domains/domain1/applications/${APPLICATION_NAME}/WEB-INF/web.xml
## Enable application
echo ":::: Step: Enable application ::::"
${LOCAL_GLASSFISH}/bin/asadmin enable ${APPLICATION_NAME}
echo ":::: Streamflow webclient is now available at http://localhost:8080/${CONTEXT_ROOT} ::::"