2 ################################################################################
4 # File: update_machine_info
5 # Description: Updates machine infor file (/vob/admin/machines)
6 # Author: Andrew@DeFaria.com
7 # Created: Fri Apr 30 14:13:56 PDT 1999
10 # (c) Copyright 2001, Andrew@DeFaria.com, all rights reserved
12 ################################################################################
13 # Set me to command name
17 adm_base=${adm_base:-$HOME/adm}
20 adm_fpath=${adm_fpath:-$adm_base/functions}
26 machines=${machines:-$adm_base/data/machines}
28 tmp_file=/tmp/machines.$$
36 while getopts v OPT; do
43 if [ -x /usr/atria/bin/cleartool ]; then
44 ccversion=$(/usr/atria/bin/cleartool -version | grep "ClearCase version" |
47 eclipseid=`ls -ld /usr/eclipse/etc 2> /dev/null | awk -F'> ' '{print $2}'
49 | awk -F/ '{print $3}'`
50 [ $? -ne 0 ] && eclipseid="No Eclipse" || eclipseid=${eclipseid#eclipse}
52 ccversion="Non ClearCase Machine"
53 eclipseid="No Eclipse"
62 # Unix doesn't really have a way to store such information such as owner,
63 # usage and location. Attempt to ascertain this info from /etc/motd.
64 if [ -f /etc/motd ]; then
65 usage=$(grep "^Usage:" /etc/motd | tr -s " " | cut -f2- -d" ")
66 owner=$(grep "^Owner:" /etc/motd | tr -s " " | cut -f2- -d" ")
67 phone=$(grep "^Phone: " /etc/motd | tr -s " " | cut -f2- -d" ")
68 class=$(grep "^Class:" /etc/motd | tr -s " " | cut -f2- -d" ")
69 location=$(grep "^Location:" /etc/motd | tr -s " " | cut -f2- -d" ")
74 if [ $verbose = "true" ]; then
75 print "Machine: $machine"
76 print "IP Address: $ip"
78 print "OS Version: $osversion"
79 print "ClearCase Version: $ccversion"
84 print "Location: $location\n"
85 print "Eclipse ID: $eclispeid\n"
86 print "Updating machine list...\c"
89 # Add machine if not already present
90 grep "^$machine" $machines > /dev/null 2>&1
93 print "$machine" >> $machines
97 if [ "$(print $line | cut -f1 -d:)" = $machine ]; then
99 "$machine:$ip:$mod:$osversion:$ccversion:$owner:$phone:$usage:$class:$location:$eclipseid"
102 print $line >> $tmp_file
106 mv $tmp_file $machines
108 if [ $verbose = "true" ]; then