2 ################################################################################
4 # File: update_machine_info
5 # Description: Updates machine info file ($adm_base/data/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:-//sonscentral/Corporate/Software/adm}
20 adm_fpath=${adm_fpath:-$adm_base/functions}
26 machines=${machines:-$adm_base/data/machines}
28 tmp_file=/tmp/machines.$$
29 machine=$(uname -n | tr [:upper:] [:lower:])
30 ip=$(ipconfig | grep "IP Address" | awk '{ print $NF }')
32 osversion=$(uname -s | sed 's/CYGWIN_//')
36 while getopts vd OPT; do
46 cleartool=$(type -p cleartool)
47 debug "cleartool = $cleartool"
49 if [ ! -z "$cleartool" ]; then
50 ccversion=$("$cleartool" -version | head -1)
52 ccversion="Non ClearCase Machine"
55 debug "ccversion = $ccversion"
56 if [[ $ccversion = *ClearCase\ LT* ]]; then
57 debug "Found Clearcase LT"
58 ccversion="Lite $(echo $ccversion | cut -c30-40)"
59 elif [[ $ccversion = *ClearCase\ version* ]]; then
60 debug "Found Clearcase version"
61 ccversion="Full $(echo $ccversion | cut -f3 -d' ')"
64 debug "ccversion = $ccversion"
65 # Unix doesn't really have a way to store such information such as owner,
66 # usage and location. Attempt to ascertain this info from /etc/motd.
67 if [ -f /etc/motd ]; then
68 owner=$(grep "^Owner:" /etc/motd | tr -s " " | cut -f2- -d" ")
69 usage=$(grep "^Usage:" /etc/motd | tr -s " " | cut -f2- -d" ")
70 phone=$(grep "^Phone: " /etc/motd | tr -s " " | cut -f2- -d" ")
71 class=$(grep "^Class:" /etc/motd | tr -s " " | cut -f2- -d" ")
72 location=$(grep "^Location:" /etc/motd | tr -s " " | cut -f2- -d" ")
75 if [ -z "$owner" ]; then
79 if [ -z "$usage" ]; then
83 if [ -z "$phone" ]; then
87 if [ -z "$class" ]; then
91 if [ -z "$location" ]; then
97 if [ $verbose = "true" ]; then
98 echo "Machine: $machine"
99 echo "IP Address: $ip"
101 echo "OS Version: $osversion"
102 echo "ClearCase Version: $ccversion"
107 echo -e "Location: $location\n"
108 echo -e "Updating machine list...\c"
111 # Add machine if not already present
112 grep -i "^$machine" $machines > /dev/null 2>&1
114 if [ $? -ne 0 ]; then
115 echo "$machine" >> $machines
119 if [ "$(echo $line | cut -f1 -d:)" = $machine ]; then
120 echo "$machine:$ip:$mod:$osversion:$ccversion:$owner:$phone:$usage:$class:$location:" >> $tmp_file
122 echo $line >> $tmp_file
126 mv $tmp_file $machines
128 if [ $verbose = "true" ]; then