forked from RedHatGov/ansible-scan-jboss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scan-jboss
executable file
·159 lines (140 loc) · 4.25 KB
/
scan-jboss
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/bash
#
# This script finds and classifies JBoss AS instances by specific community and
# enterprise releases.
#
# Classification is simple: search for jboss-modules.jar and run.jar files and
# then extract the version from the pom.properties and MANIFEST.MF,
# respectively, to determine which distribution contained the jar
#
# NB: This script is up to date through EAP 6.4 CP04 and WildFly 10.0.0.CR3
# abort if error
set -e
# default arguments for the scanning module
WorkDir=/tmp
ClassificationFile=scan-jboss-classifier.txt.$$
MatchingReleaseFile=scan-jboss-release-list.$$
SearchRoot=/
#SearchRoot=/Users/rlucente/demo/eap-test
# get overrides for the above arguments from ansible
# this is potentially dangerous as arbitrary command execution can occur
if [ $# -gt 0 ]
then
source ${1}
fi
# switch to scratch directory
pushd ${WorkDir} 2>&1 > /dev/null
# populate the classifier file used to match the jboss release
#
# this file is simply formatted as:
# release-name ':' version-string
#
# where version-string refers to the jboss-modules.jar version or the
# Implementation-Version in the run.jar MANIFEST.MF file.
#
# there can be multiple versions if jboss-modules.jar was patched
#
cat > ${ClassificationFile} <<EOF1
JBossAS-4: JBoss_4_0_0
JBossAS-4: JBoss_4_0_1_SP1
JBossAS-4: JBoss_4_0_2
JBossAS-4: JBoss_4_0_3_SP1
JBossAS-4: JBoss_4_0_4_GA
JBossAS-4: Branch_4_0
JBossAS-4: JBoss_4_2_0_GA
JBossAS-4: JBoss_4_2_1_GA
JBossAS-4: JBoss_4_2_2_GA
JBossAS-4: JBoss_4_2_3_GA
JBossAS-5: JBoss_5_0_0_GA
JBossAS-5: JBoss_5_0_1_GA
JBossAS-5: JBoss_5_1_0_GA
JBossAS-6: JBoss_6.0.0.Final
JBossAS-6: JBoss_6.1.0.Final
JBossAS-7: 1.0.1.GA
JBossAS-7: 1.0.2.GA
JBossAS-7: 1.1.1.GA
JBossAS-7: 1.2.0.CR1
WildFly-8: 1.2.0.Final
WildFly-8: 1.2.2.Final
WildFly-8: 1.2.4.Final
WildFly-8: 1.3.0.Beta3
WildFly-8: 1.3.0.Final
WildFly-8: 1.3.3.Final
WildFly-9: 1.3.4.Final
WildFly-9: 1.4.2.Final
WildFly-9: 1.4.3.Final
WildFly-10: 1.4.3.Final
WildFly-10: 1.4.4.Final
EAP-4.2: JBPAPP_4_2_0_GA
EAP-4.2: JBPAPP_4_2_0_GA_C
EAP-4.3: JBPAPP_4_3_0_GA
EAP-4.3: JBPAPP_4_3_0_GA_C
EAP-5.0.0: JBPAPP_5_0_0_GA
EAP-5.0.1: JBPAPP_5_0_1
EAP-5.1.0: JBPAPP_5_1_0
EAP-5.1.1: JBPAPP_5_1_1
EAP-5.1.2: JBPAPP_5_1_2
EAP-5.2.0: JBPAPP_5_2_0
EAP-6.0.0: 1.1.2.GA-redhat-1
EAP-6.0.1: 1.1.3.GA-redhat-1
EAP-6.1.0: 1.2.0.Final-redhat-1
EAP-6.1.1: 1.2.2.Final-redhat-1
EAP-6.2: 1.3.0.Final-redhat-2
EAP-6.2: 1.3.3.Final-redhat-1
EAP-6.3: 1.3.3.Final-redhat-1
EAP-6.3: 1.3.4.Final-redhat-1
EAP-6.3: 1.3.5.Final-redhat-1
EAP-6.4: 1.3.6.Final-redhat-1
EAP-6.4: 1.3.7.Final-redhat-1
EOF1
touch $MatchingReleaseFile
MODDIR="META-INF/maven/org.jboss.modules/jboss-modules"
# find every occurrence of the modules jar in the filesystem (excluding
# redundant copies from patching)
for jar in `find ${SearchRoot} -type f -name 'jboss-modules.jar' | \
grep -v '\.installation/patches'`
do
jar xf ${jar} ${MODDIR}/pom.properties
VERSION=`grep version ${MODDIR}/pom.properties | sed 's/version=//g'`
if [ ! -z "${VERSION}" ]
then
FOUND=`grep ${VERSION}\$ ${ClassificationFile} | cut -d':' -f1`
if [ -z "${FOUND}" ]
then
FOUND="Unknown-JBoss-Release"
fi
for fnd in `echo $FOUND`
do
echo ${fnd} >> ${MatchingReleaseFile}
done
rm -fr META-INF
fi
done
# find every occurrence of the run jar in the filesystem
for runjar in `find ${SearchRoot} -type f -name 'run.jar'`
do
jar xf ${runjar} META-INF/MANIFEST.MF
VERSION=`grep Implementation-Version META-INF/MANIFEST.MF | \
tr '\r\n' ' ' | \
sed 's/..*[CS]V[NS]Tag.//g' | cut -d' ' -f1`
if [ ! -z "${VERSION}" ]
then
FOUND=`grep ${VERSION}\$ ${ClassificationFile} | cut -d':' -f1`
if [ -z "${FOUND}" ]
then
FOUND="Unknown-JBoss-Release"
fi
for fnd in `echo $FOUND`
do
echo ${fnd} >> ${MatchingReleaseFile}
done
rm -fr META-INF
fi
done
RELEASE_LIST=`sort -u ${MatchingReleaseFile} | tr '\n' ',' | sed 's/,/, /g' | sed 's/, $//g'`
rm -f ${ClassificationFile} ${MatchingReleaseFile}
popd 2>&1 > /dev/null
echo -n "hostname=`hostname` "
echo -n "cores=`grep 'cpu cores' /proc/cpuinfo | awk '{s+=$4} END {print s}'` "
echo "release=\"${RELEASE_LIST}\" changed=False"
exit 0