28
|
1 |
#!/bin/bash |
|
2 |
# checkwardir.sh - Made for Puppi |
|
3 |
|
|
4 |
# Sources common header for Puppi scripts |
|
5 |
. $(dirname $0)/header || exit 10 |
|
6 |
|
|
7 |
# Show help |
|
8 |
showhelp () { |
|
9 |
echo "This script is used to check if a webapp directory is successfully created or removed" |
|
10 |
echo " after the (un)deploy of a war file" |
|
11 |
echo "It implies that a directory with the name of the war file is created in the same path" |
|
12 |
echo "-p <warname> - Waits until war created dir is present" |
|
13 |
echo "-a <warname> - Wait until war created dir is absent" |
|
14 |
echo "-s <seconds> - Wait some more seconds after the check" |
|
15 |
echo "-c <configentry> - Name of the runtime config variable that contains the warname" |
|
16 |
echo "Examples:" |
|
17 |
echo "checkwardir.sh -p /store/tomcat/myapp/webapps/myapp.war" |
|
18 |
echo "checkwardir.sh -a /store/tomcat/myoldapp/webapps/myoldapp.war" |
|
19 |
} |
|
20 |
|
|
21 |
seconds=2 |
|
22 |
|
|
23 |
while [ $# -gt 0 ]; do |
|
24 |
case "$1" in |
|
25 |
-s) |
|
26 |
seconds=$2 |
|
27 |
shift 2 |
|
28 |
;; |
|
29 |
-p) |
|
30 |
check="present" |
|
31 |
warname=$2 |
|
32 |
shift 2 |
|
33 |
;; |
|
34 |
-a) |
|
35 |
check="absent" |
|
36 |
warname=$2 |
|
37 |
shift 2 |
|
38 |
;; |
|
39 |
-c) |
|
40 |
warname="$(eval "echo \${$(echo ${2})}")" |
|
41 |
shift 2 |
|
42 |
;; |
|
43 |
*) |
|
44 |
showhelp |
|
45 |
exit |
|
46 |
;; |
|
47 |
esac |
|
48 |
done |
|
49 |
|
|
50 |
checkdir () { |
|
51 |
wardir=${warname%\.*} |
|
52 |
while true |
|
53 |
do |
|
54 |
if [ $check == absent ] ; then |
|
55 |
[ ! -d $wardir ] && break |
|
56 |
else |
|
57 |
[ -f $wardir/WEB-INF/web.xml ] && break |
|
58 |
fi |
|
59 |
sleep $seconds |
|
60 |
done |
|
61 |
} |
|
62 |
|
|
63 |
checkdir |