Initial add of defaria.com
[clearscm.git] / defaria.com / Computers / code / adm / bin / infrastructuremach
1 #!/bin/bash
2 ################################################################################
3 #
4 # File:         infrastructuremach
5 # Description:  A script to execute a command on all infrastructure 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 infrastructure_machine in $(grep -ve ^# $machines | grep Infrastructure
43 | cut -d: -f1); do
44   # Execute command. Note if no command is given then the effect is to
45   # rlogin to each machine.
46   print "$infrastructure_machine:$@"
47   if [ $# -gt 0 ]; then
48     if [ -z "$root" ]; then
49       remsh $infrastructure_machine -n "$@"
50     else
51       root remsh $infrastructure_machine -n "$@"
52     fi
53   else
54     if [ -z "$root" ]; then
55       remsh $infrastructure_machine
56     else
57       root remsh $infrastructure_machine
58     fi
59   fi
60 done