Added client work scripts
[clearscm.git] / clients / HP / bin / desktopmach
1 #!/bin/ksh
2 ################################################################################
3 #
4 # File:         desktopmach
5 # Description:  A script to execute a command on all desktop 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:-$HOME/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 desktop_machine in $(grep -ve ^# $machines | grep :Desktop: | cut -d:
43 -f1); do
44   # Execute command. Note if no command is given then the effect is to
45   # rlogin to each machine.
46   print "$desktop_machine:$@"
47   if [ $# -gt 0 ]; then
48     if [ -z "$root" ]; then
49       remsh $desktop_machine -n "$@"
50     else
51       root remsh $desktop_machine -n "$@"
52     fi
53   else
54     if [ -z "$root" ]; then
55       remsh $desktop_machine
56     else
57       root remsh $desktop_machine
58     fi
59   fi
60 done