File: mk.qa_hosts

package info (click to toggle)
pcp 3.9.10
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 81,836 kB
  • ctags: 26,423
  • sloc: ansic: 178,791; sh: 79,349; cpp: 61,042; xml: 28,842; perl: 12,963; yacc: 5,351; python: 4,578; lex: 1,894; makefile: 1,665; fortran: 60; java: 22; awk: 20
file content (83 lines) | stat: -rwxr-xr-x 1,906 bytes parent folder | download | duplicates (3)
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
#! /bin/sh
#
# make qa_hosts from qa_hosts.master
#
# Copyright (c) 1997-2002 Silicon Graphics, Inc.  All Rights Reserved.
#

iam=mk.qa_hosts

# Need to clear some environment variables so that behaviour is the same
# when we're called via make from common.check, where the environment has
# already been set in common.check and possibly modified in make to include
# parenthesis around the value, e.g. PCP_AWK_PROG="/usr/bin/gawk --posix"
# which blows up below otherwise.
#
# Unsetting PCP_ENV_DONE forces pcp.env to be sourced again, and unsetting
# PCP_AWK_PROG allows it to be assigned a new value.
#
unset PCP_ENV_DONE
unset PCP_AWK_PROG

# generic initialization
. ./common.rc

if [ ! -f qa_hosts.master ]
then
    echo "$0: Cannot find \"qa_hosts.master\""
    exit 1
fi

if [ -f qa_hosts -a ! -w qa_hosts ]
then
    echo "$0: Cannot write \"qa_hosts\""
    exit 1
fi

my_host=`hostname | sed -e 's/\..*//'`
my_fqdn=`pmhostname`
if [ -z "$my_fqdn" -o "$my_host" = "$my_fqdn" ]; then
    if [ -x /bin/domainname ]; then
        my_domain=`domainname`
        [ -z "$my_domain" ] || my_fqdn=${my_host}.${my_domain}
    fi
fi
[ -z "$my_fqdn" -o "$my_host" = "$my_fqdn" ] && my_fqdn=$my_host".localdomain"

rm -f qa_hosts
grep "^#order" qa_hosts.master \
| while read tag pat recipe
do
    if echo $my_fqdn | fgrep "$pat" >/dev/null 2>&1
    then
	trap "rm -f /tmp/$$; exit 1" 1 2 3 15

	# strip qa_hosts.master leaving only hosts
	#
	sed -e 's/#.*//' -e '/^ *$/d' qa_hosts.master >/tmp/$$

	# match in turn
	#
	for sel in $recipe
	do
	    fgrep $sel /tmp/$$ \
	    | $PCP_AWK_PROG '
BEGIN	{ srand('$$') }
	{ print 100*rand(),$0 }' \
	    | LC_COLLATE=POSIX _POSIX2_VERSION=0 sort +0n -1 \
	    | cut -d' ' -f2 >>qa_hosts
	done

	rm -f /tmp/$$
	break
    fi
done

if [ ! -f qa_hosts ]
then
    echo "$0: no #order line matches this host \"$my_fqdn\", local testing only"
    touch qa_hosts
fi

exit 0