summaryrefslogtreecommitdiff
path: root/qa/admin/check-vm
blob: 4e0a5c4c630e0c68edbba781049359a8ebff29c6 (plain)
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
#!/bin/sh
#
# Check what's installed on a PCP/PCPQA VM looking for missing apps
# and packages
#

_usage()
{
    echo "Usage: $0 [-v]"
    exit 1
}

verbose=false
while getopts 'v?' p
do
    case "$p"
    in
	v)	verbose=true
		;;

	?)	_usage
		# NOTREACHED
    esac
done
shift `expr $OPTIND - 1`
[ $# -eq 0 ] || _usage

tmp=/var/tmp/$$
trap "rm -f $tmp.*; exit 0" 0 1 2 3 15

# add additional and optional directories
for dir in /sbin /usr/sbin
do
    if [ -d "$dir" ]
    then
	if echo ":$PATH:" | grep -q ":$dir:"
	then
	    :
	else
	    export PATH="$PATH:$dir"
	    #debug# echo add $dir to \$PATH
	fi
    fi
done

# perl ? apt-get install -qqy --force-yes libxml-tokeparser-perl
# perl ? apt-get install -qqy --force-yes libspreadsheet-read-perl
cat <<End-of-File >$tmp.control
# one line per app, alternate items separated by white space
# first item ending in ? means this item is a guard, if it does not
# exist silently ignore the rest of the line
# tests items can be
#	starting with a /	test for existence of file or directory
#                               (alternates separated by |)
#	containing ::		test for presence of the associated Perl module
#	otherwise		test for an executable with which(1)
#                               (alternates separated by |)
#
# text after # is treated as a comment
# text after [ is treated as annotation
#
# executables
ed
git
make
gcc
autoconf
flex
bison
gdb
mktemp
gawk
# optional executables
dpkg?	dpkg-buildpackage	[dpkg-dev]
dpkg?	dh			[debhelper]
dpkg?	chrpath			[chrpath]
dpkg?	sysv-rc-conf		[sysv-rc-conf]
rpm?	rpmbuild		[rpm-build]
# other build prerequisites
dpkg?	/usr/share/doc/pkg-config	[pkg-config]
dpkg?	/usr/share/doc/python-all-dev	[python-all-dev]
dpkg?	/usr/include/microhttpd.h	[libmicrohttpd-dev]
rpm?	/usr/include/microhttpd.h	[libmicrohttpd-devel]
dpkg?	/usr/include/sasl/sasl.h	[libsasl2-dev]
rpm?	/usr/include/sasl/sasl.h	[cyrus-sasl-devel]
rpm?	/usr/include/systemd/sd-daemon.h	[systemd-devel but not for CentOS 5.8]
dpkg?	/usr/include/infiniband/umad.h	[libibumad-dev]
rpm?	/usr/include/infiniband/umad.h	[libibumad-devel]
dpkg?	/usr/include/infiniband/mad.h	[libibmad-dev]
rpm?	/usr/include/infiniband/mad.h	[libibmad-devel]
dpkg?	/usr/include/avahi-common	[libavahi-common-dev]
rpm?	/usr/include/avahi-common	[avahi-devel]
dpkg?	g++				[g++]
rpm?	g++				[gcc-c++]
# files
dpkg?	/usr/include/readline/readline.h	[libreadline-dev]
rpm?	/usr/include/readline/readline.h	[readline-devel]
rpm?	/usr/include/ncurses.h	[ncurses-devel] # is this a bug in the spec file?
# perl modules
Time::HiRes			[Perl Time-HiRes perl-Time-HiRes(rpm)]
Date::Format			[Perl TimeDate perl-TimeDate(rpm)]
Date::Parse			[Perl TimeDate perl-TimeDate(rpm)]
Getopt::Std			[base Perl]
dpkg?	ExtUtils::MakeMaker	[libextutils-autoinstall-perl]
rpm?	ExtUtils::MakeMaker	[perl-ExtUtils-MakeMaker]
dpkg?	XML::TokeParser		[libxml-tokeparser-perl]
rpm?	XML::TokeParser		[perl-XML-TokeParser]
Spreadsheet::Read		[libspreadsheet-read-perl(dpkg)]
dpkg?	Spreadsheet::WriteExcel	[libspreadsheet-writeexcel-perl]
rpm?	Spreadsheet::WriteExcel	[perl-Spreadsheet-WriteExcel]
Spreadsheet::ReadSXC		[cpan?]
# other run-time
sadf				[sysstat]
# QA
bc
curl
Spreadsheet::XLSX		[libspreadsheet-xlsx-perl(dpkg)]
dpkg?	Text::CSV_XS		[Text-CSV_XS]
rpm?	Text::CSV_XS		[perl-Text-CSV_XS]
crontab				[from vixie-cron?]
valgrind
dpkg?	mail			[bsd-mailx]
rpm?	mail			[mailx]
host				[bind-utils(redhat)]
dpkg?	apache2			[apache2]
rpm?	httpd			[httpd]
time				[time(redhat)]
dpkg?	realpath		[realpath]
# pcp-gui
dpkg?	qmake			[qt4-qmake]
rpm?	qmake|qmake-qt4			[qt-devel]
dpkg?	/usr/lib/libQtCore.so|/usr/lib/*/libQtCore.so	[libqt4-dev]
dpkg?	/usr/lib/libSoQt4.so|/usr/lib/*/libSoQt4.so	[libsoqt4-dev]
rpm?	/usr/lib/libQtCore.so|/usr/lib*/libQtCore.so	[qt-devel]
dpkg?	/usr/include/Inventor/Qt/SoQt.h	[libsoqt-dev-common]
dpkg?	/usr/include/Inventor/SoPath.h	[libcoin60-dev or libcoin80-dev]
# python
rpm?	/usr/include/python*/Python.h		[python-devel]
dpkg?	/usr/include/python*/Python.h		[python-dev]
# nss
dpkg?	/usr/include/nspr/nspr.h	[libnspr4-dev]
rpm?	/usr/include/nspr4/nspr.h	[nspr-devel]
dpkg?	/usr/include/nss/nss.h		[libnss3-dev]
rpm?	/usr/include/nss3/nss.h		[nss-devel]
dpkg?	certutil			[libnss3-tools]
rpm?	certutil			[nss-tools]
End-of-File

if which python >/dev/null 2>&1
then
    # For python-ctypes, check for python before 2.5 ... expect something like
    # Python 2.7.3
    eval `python -V 2>&1 | sed -e 's/Python //' -e 's/^/maj=/' -e 's/\./ min=/' -e 's/\..*//'`
    if [ -n "$maj" -a -n "$min" ]
    then
	rm -f $tmp.need
	if [ "$maj" -lt 2 ]
	then
	    touch $tmp.need
	elif [ "$maj" -eq 2 -a "$min" -lt 5 ]
	then
	    touch $tmp.need
	fi
	[ -f $tmp.need ] && \
	    echo "rpm?	/usr/share/doc/packages/python-ctypes	[python-ctypes]" >>$tmp.control
    fi
fi

cat $tmp.control \
| sed -e 's/#.*//' -e '/^[ 	]*$/d' \
| while read apps
do
    rm -f $tmp.ok
    for app in $apps
    do
	case $app
	in
	    \[*)
	    	break
		;;
	    *\?)
	    	app=`echo $app | sed -e 's/?$//'`
		optional=true
		;;
	    *)
		optional=false
		;;
	esac
	case $app
	in
	    \[*)
	    	break
		;;
	    /*)
		rm -f $tmp.tmp
		for file in `echo "$app" | sed -e 's/|/ /g'`
		do
		    if [ -f "$file" -o -d "$file" ]
		    then
			touch $tmp.tmp
			break
		    fi
		done
		[ -f $tmp.tmp ]
		ok=$?
		;;
	    *::*)
		echo "use $app;" | perl >/dev/null 2>&1
		ok=$?
		;;
	    *)
		rm -f $tmp.tmp
		for exec in `echo "$app" | sed -e 's/|/ /g'`
		do
		    if which $exec >/dev/null 2>&1
		    then
			touch $tmp.tmp
			break
		    fi
		done
		[ -f $tmp.tmp ]
		ok=$?
		;;
	esac
	if $verbose
	then
	    echo -n " .. $app"
	    $optional && echo -n "[optional]"
	    if [ $ok = 0 ]
	    then
		echo -n " yes"
	    else
		echo -n " no"
	    fi
	fi
	if [ $ok = 0 ]
	then
	    $optional && continue
	    touch $tmp.ok
	    break
	else
	    if $optional
	    then
		# guard not true, skip checks for other apps
		touch $tmp.ok
		break
	    fi
	fi
    done
    $verbose && echo
    if [ ! -f $tmp.ok ]
    then
	echo "Missing: `echo $apps \
	    | sed \
		-e 's/[ 	][ 	]*/ /g' \
		-e '/ /{
s/? /?@/
:loop1
s/\(\[.*\) /\1@/
t loop1
:loop2
s/ \([^[]\)/@|@\1/
t loop2
s/@/ /g
}'`"
    fi
done

# Some platform-specific and special case tests
#
if which dpkg >/dev/null 2>&1
then
    # Debian based
    #
    dpkg -l >$tmp.tmp
    for pkg in python-all python-all-dev
    do
	if grep "^ii *$pkg" <$tmp.tmp >/dev/null
	then
	    :
	else
	    echo "Need # apt-get install $pkg"
	fi
    done
fi

# Networking goo
#
_check_host()
{
    ipaddr=`sed -n </etc/hosts -e '/^#/d' -e '/::/d' -e 's/$/ /' -e "/[ 	]$1[ 	]/"'{
s/[ 	].*//
p
}'`
    if [ -z "$ipaddr" ]
    then
	echo "No /etc/hosts entry for $1"
	return
    fi

    if [ `echo "$ipaddr" | wc -l | sed -e 's/  *//g'` -gt 1 ]
    then
	echo "Multiple /etc/hosts entries for $1"
	return
    fi

    ifconfig \
    | awk '
/^[^ 	]/	{ iface = $1; next }
/inet addr:'$ipaddr' / || /inet '$ipaddr' / {
			  if (iface == "lo")
			    print "Warning: '$1' associated with loopback network interface"
			  found = 1
			  exit
			}
END		{ if (found != 1)
		    print "Warning: '$1' ('$ipaddr') not associated with a network interface"
		}'
}

host=`hostname`
_check_host $host
if which pmhostname >/dev/null 2>&1
then
    pmhost=`pmhostname`
    if [ -z "$pmhost" ]
    then
	echo "Warning: pmhostname returns nothing!"
    else
	case $pmhost
	in
	    $host|$host.*)
		    ;;
	    *)
		    echo "Warning: hostname ($host) is not a prefix of pmhostname ($pmhost)"
		    ;;
	esac
	_check_host $pmhost
    fi
fi

if [ -f /etc/pcp.conf ]
then
    . /etc/pcp.conf

    # need QA access to pmlogger via pmlc
    #
    if [ -f $PCP_SYSCONF_DIR/pmlogger/config.default ]
    then
	if grep -q 'allow 192\.168\.1\.\*' $PCP_SYSCONF_DIR/pmlogger/config.default
	then
	    :
	else
	    echo "Missing: \"allow 192.168.1.* : all;\" [access] in $PCP_SYSCONF_DIR/pmlogger/config.default"
	fi
    else
	echo "Warning: \"$PCP_SYSCONF_DIR/pcp/pmlogger/config.default\" is missing"
    fi
else
    echo "Warning: \"/etc/pcp.conf\" is missing"
fi