Initial add of defaria.com
[clearscm.git] / defaria.com / Computers / code / adm / bin / testmach
1 #!/bin/bash
2 ################################################################################
3 #
4 # File:         testmach
5 # Description:  A script to execute a command on all test class machines
6 # Author:       Andrew@DeFaria.com
7 # Created:      Thu May 11 11:08:24 PDT 2000
8 # Modified:
9 # Language:     Korn Shell
10 #
11 # (c) Copyright 2001, Andrew@DeFaria.com, all rights reserved
12 #
13 ################################################################################
14 # Set me to command name
15 me=$(basename $0)
16
17 # Set adm_base
18 adm_base=${adm_base:-//sonscentral/Corporate/Software/adm}
19
20 # Set adm_fpath
21 adm_fpath=${adm_fpath:-$adm_base/functions}
22
23 # Source functions
24 . $adm_fpath/common
25
26 # Set machines
27 machines=${machines:-$adm_base/data/machines}
28
29 if [ "$1" = "-f" ]; then
30   shift
31   machines="$1"
32   shift
33 fi
34
35 PATH=/adm/bin:$PATH
36
37 if [ "$1" = "-r" ]; then
38   root=yes
39   shift
40 fi
41
42 for test_machine in $(grep -ve ^# $machines | grep :Test: | cut -d: -f1); do
43   # Execute command. Note if no command is given then the effect is to
44   # rlogin to each machine.
45   print "$test_machine:$@"
46   if [ $# -gt 0 ]; then
47     if [ -z "$root" ]; then
48       remsh $test_machine -n "$@"
49     else
50       root remsh $test_machine -n "$@"
51     fi
52   else
53     if [ -z "$root" ]; then
54       remsh $test_machine
55     else
56       root remsh $test_machine
57     fi
58   fi
59 done