-
Notifications
You must be signed in to change notification settings - Fork 0
/
chkdist.sh
executable file
·136 lines (114 loc) · 3.28 KB
/
chkdist.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/sh
#
# A script to validate an RHQ distribution zipfile.
#
abort()
{
_MSG="$1"
if [ -n "$_MSG" ]; then
echo "$_MSG" >&2
fi
echo "Usage: $SCRIPT_NAME rhq-dist-zipfile" >&2
exit 1
}
pass()
{
_MSG="$1"
echo "[PASSED] $_MSG"
return 0
}
fail()
{
_MSG="$1"
echo "[FAILED] $_MSG"
EXIT_CODE=2
return 1
}
chkfile()
{
_PATH=`eval echo $1`
_DESC="$2"
_COUNT=`ls -d1 "$_PATH" 2>/dev/null | wc -l`
if [ $_COUNT -eq 1 ]; then
pass "$_DESC is included."
else
fail "$_DESC ($_PATH) is missing."
fi
return $?
}
chknofile()
{
_PATH=`eval echo $1`
_DESC="$2"
_COUNT=`ls -d1 "$_PATH" 2>/dev/null | wc -l`
if [ $_COUNT -eq 0 ]; then
pass "$_DESC is not included."
else
fail "$_DESC ($_PATH) is present."
fi
return $?
}
chkdir()
{
_PATH="$1"
_DESC="$2"
if [ -d "$_PATH" ]; then
pass "$_DESC is included."
else
fail "$_DESC ($_PATH) is missing."
fi
return $?
}
SCRIPT_NAME=`basename $0`
RHQ_DIST_ZIPFILE="$1"
# Validate arguments.
[ -z "$RHQ_DIST_ZIPFILE" ] && abort "Argument missing."
[ -d "$RHQ_DIST_ZIPFILE" ] && abort "$RHQ_DIST_ZIPFILE is a directory, not a regular file."
[ ! -e "$RHQ_DIST_ZIPFILE" ] && abort "$RHQ_DIST_ZIPFILE does not exist."
# Check zip file dize is in expected range.
ZIPFILESIZE=`ls -l "$RHQ_DIST_ZIPFILE" | awk '{print $5}'`
if [ "$ZIPFILESIZE" -lt 185000000 ]; then
fail "Dist zipfile size is less than 185 MB."
elif [ "$ZIPFILESIZE" -gt 200000000 ]; then
fail "Dist zipfile size is greater than 200 MB."
else
pass "Dist zipfile size is between 185 and 200 MB."
fi
# Unzip the dist zip to a temp dir.
TMP_DIR="/tmp/chkdist$$"
unzip -q "$RHQ_DIST_ZIPFILE" -d $TMP_DIR
# e.g.: /tmp/chkdist12345/rhq-server-4.0.0)
RHQ_DIR=`ls -d $TMP_DIR/*`
AS_CONFIG_DIR="$RHQ_DIR/jbossas/server/default"
RHQ_EAR_DIR="$AS_CONFIG_DIR/deploy/rhq.ear.rej"
EXIT_CODE=0
# Check for existence of various dirs and files.
chkdir "$RHQ_EAR_DIR" "RHQ EAR"
chknofile "$RHQ_EAR_DIR/rhq-downloads/connectors/connector-apache.zip" "Apache Connectors zipfile"
chkfile "$RHQ_EAR_DIR/rhq-downloads/connectors/connector-rtfilter.zip" "Servlet RT Connectors zipfile"
chkfile "$AS_CONFIG_DIR/lib/postgresql-*.jar" "PostgreSQL JDBC driver"
chknofile "$AS_CONFIG_DIR/lib/ojdbc5-*.jar" "Oracle JDBC driver"
# Check that JSPs are precompiled.
if [ -f "$RHQ_EAR_DIR/rhq-portal.war/WEB-INF/classes/jsp/portal/MainLayout_jsp.class" ]; then
pass "JSPs are precompiled."
else
fail "JSPs are not precompiled."
fi
# Check that no SNAPSHOT jars are included.
SNAPSHOT_JARS=`find "$RHQ_EAR_DIR" -name "*-SNAPSHOT.jar"`
if [ -z "$SNAPSHOT_JARS" ]; then
pass "No snapshot jars are included."
else
fail "The following snapshot jars are included:"
echo "$SNAPSHOT_JARS"
fi
# Check encoding of message bundles.
ENCODING=`file $RHQ_DIR/jbossas/server/default/deploy/rhq-installer.war/WEB-INF/classes/InstallerMessages_de.properties | cut -d: -f2 | cut -d' ' -f2`
if [ "$ENCODING" = "ISO-8859" ]; then
pass "Message bundle encoding is correct."
else
fail "Message bundle encoding is incorrect (expected: ISO-8859, actual: $ENCODING). LANG environment variable was probably not set to en_US.iso88591 in shell that was used to build the release."
fi
# Cleanup.
rm -rf "$TMP_DIR"
exit $EXIT_CODE