-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
45 lines (40 loc) · 1.19 KB
/
deploy.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
#!/bin/bash/
# ---------------------------------------
# Define paths to deploy the .war archive
# ---------------------------------------
DEPLOY_PATH="C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps"
WAR_PATH="./target"
WAR_EXTENSION=".war"
CLEAN_INSTALL="mvn clean && mvn install"
# ---------------------------------------
# Check if file does exists
# ---------------------------------------
check_file() {
if [[ -e ${WAR_PATH}/"$1"${WAR_EXTENSION} ]]; then
return 0
else
return 1
fi
}
# ---------------------------------------
# Logic implementation
# ---------------------------------------
if [[ $# -eq 0 ]]; then
echo -e "\e[31mError: you have not specified the name of the .war file\e[0m"
exit 1
elif !( check_file $1 ); then
echo -e "\e[33mWarning: the file specified has not been found\e[0m"
echo -e "Trying to generate it..."
eval "${CLEAN_INSTALL}"
if !( check_file $1 ); then
echo -e "\e[31mError: the file specified has not been found\e[0m"
exit -1
fi
else
eval "${CLEAN_INSTALL}"
fi
# ---------------------------------------
# All Ok
# ---------------------------------------
cp ${WAR_PATH}/$1${WAR_EXTENSION} "${DEPLOY_PATH}"
echo -e "\e[32m\nDEPLOYED SUCCESSFULLY"