home *** CD-ROM | disk | FTP | other *** search
- #! /bin/csh
- #
- # $Id: update.hosts,v 1.16 1994/02/22 21:50:57 carlson Exp carlson $
- #
- # Should be run by cron. Goes out to all the hosts in
- # the .rhosts file and finds those hosts that have the
- # same domain as the local host and makes sure the
- # required files are up-to-date.
- #
- # Revision History:
- # $Log: update.hosts,v $
- # Revision 1.16 1994/02/22 21:50:57 carlson
- # Lots of changes.
- #
- # Revision 1.15 1993/12/16 14:50:07 carlson
- # Modified to use rdist instead of doing it all myself.
- #
- # Revision 1.14.1.1 93/11/17 14:20:00 carlson
- # This is an attempt to get this program to use rdist instead of doing
- # the work myself. Unfortunately, I couldn't get the 'except'
- # clause to work as advertised.
- #
- # Revision 1.14 93/11/17 09:35:35 carlson
- # Need to compute the number of arguments more than once so set a variable
- # to this value and use the variable.
- # Added more files to the list of files not copied.
- # Make it so that we can update just one host by specifying it on the
- # command line.
- #
- # Revision 1.13 93/08/18 18:08:42 carlson
- # Added tuck to the bad hosts list.
- # Removed stuff for updating home.
- #
- # Revision 1.12 93/06/11 16:34:38 carlson
- # Added bikini to bad hosts list.
- #
- # Revision 1.11 93/06/02 11:03:52 carlson
- # Removed tuck from the bad_hosts list.
- #
- # Revision 1.10 93/03/29 09:23:20 carlson
- # Added tuck to bad hosts list.
- # Added code to send new stuff home whenever it is done.
- #
- # Revision 1.9 93/01/06 17:43:13 carlson
- # Modified documentation to include log.
- # Added documentation.
- # Modified so that it can be run interactively. If it is, then parameters
- # are passed on the command line which list the hosts to update.
- # If run interactively, don't ignore 'bad_hosts'.
- # Made it so echo and verbose flags can be set and details won't be echoed.
- #
- #-----------------------------------------------------------------------
-
- cd ~
-
- #----
- # If there are command line arguments, then this is being run
- # interactively and not by cron. Command line arguments should be the
- # hosts to update. Otherwise, get the hosts from the .rhosts file.
- #
- # Set 'hosts' to the list of hosts to update.
- #
-
- set numArgs = $#argv
- if ( $numArgs == 0 ) then
- set hosts = `cat ~/.rhosts`
- else
- set hosts = ( $argv )
- endif
-
- #----
- # Set various variables:
- #
- # dirs Directories in my home directory to copy.
- # mydomain My domain name broken into separate words.
- # myhost The hostname of the machine I'm running this on.
- # bad_files System files NOT to copy.
- # bad_hosts Hosts not to update.
- # distFile Name of file to use for input to rdist
- #
-
- set dirs = ( emacs scripts )
- set mydomain = ( `domainname | awk -F. '{for (x=1;x<NF;x++) printf "%s ",$x; print $NF}'` )
- set myhost = `hostname`
- set noglob
- set bad_files = ( \\\\.gam.* \\\\.cshrc \\\\.login \\\\.newsrc.* \
- \\\\.oldnewsrc \\\\.passwd \\\\.sessionlog \\\\.show_pro \
- \\\\.wshttymode \\\\.version \\\\.xrnsignature \\\\..sav \
- \\\\.grosview \\\\..*_version RCS \\\\.pv.* ~\\\\$ \\\\.insightrc \
- \\\\.emacs_server \\\\.vacation.* \\\\.aub.* \\\\.netlook.* )
- set non_toto = ( \\\\.chestrc \\\\.Xdefaults.* \\\\.sgisession )
- set toto_only = ( \\\\.auxchestrc \\\\.Sgiresources )
-
- unset noglob
- if ( $numArgs == 0 ) then
- set bad_hosts = ( frogskin garter capella ghost tuck )
- else
- set bad_hosts = ( )
- endif
-
- set toto_hosts = ( )
- set new_hosts = ( )
- set old_hosts = ( )
- set distFile = /usr/tmp/distfile
-
- #----
- # For each host, find out what OS it is running and put it into
- # the appropriate list. Skip this host and any host not in my
- # domain.
- #
-
- foreach host ( $hosts )
- set names = `echo $host | awk -F. '{print $1,$2,$3,$4}'`
- if ( $#names > 1 && $numArgs == 0 ) then
- if ( "$names[2]" != "$mydomain[1]" ) continue
- endif
- if ( ! { isIn $names[1] $bad_hosts } ) continue
- if ( "$names[1]" == "$myhost" ) continue
- if ( $numArgs == 0 ) then
- set dname = `domainname`
- else
- set dname = `echo $names[2-] | sed -e 's/ /./g'`
- endif
- set ver = `rsh $host uname -r`
- set vernum = `echo $ver | awk -F- '{print $1}'`
- set vers = `echo $vernum | awk -F. '{print $1,$2}'`
- if ( $#vers < 2 ) then
- echo "Problem getting version of IRIX from $host"
- echo " ver = $ver, vernum = $vernum, vers = $vers"
- continue
- endif
- if ( "$vers[1]" == "5" ) then
- if ( "$vers[2]" == "2" ) then
- set toto_hosts = ( $toto_hosts $names[1].$dname )
- else
- set new_hosts = ( $new_hosts $names[1].$dname )
- endif
- else
- set old_hosts = ( $old_hosts $names[1].$dname )
- endif
- end
-
- #----
- # Start writing to distFile
- #
-
- if ( -e $distFile && ! -w $distFile ) then
- echo "${argv[0]}: Unable to write to $distFile"
- echo "${argv[0]}: Giving up"
- exit 1
- endif
-
- set date = `date`
- echo "# Input to rdist - $date" > $distFile
- echo "#" >> $distFile
-
- #-----
- # Actually write out the list of hosts to do.
- #
-
- if ( $#old_hosts > 0 ) then
- echo "OLDHOSTS = (" >> $distFile
- foreach host ( $old_hosts )
- echo " $host" >> $distFile
- end
- echo " )" >> $distFile
- endif
-
- if ( $#toto_hosts > 0 ) then
- echo "TOTOHOSTS = (" >> $distFile
- foreach host ( $toto_hosts )
- echo " $host" >> $distFile
- end
- echo " )" >> $distFile
- endif
-
- if ( $#new_hosts > 0 ) then
- echo "NEWHOSTS = (" >> $distFile
- foreach host ( $new_hosts )
- echo " $host" >> $distFile
- end
- echo " )" >> $distFile
- endif
-
- #-----
- # Get a list of all the files in my home directory to copy.
- #
-
- set lcl_files = ( `/bin/ls -Ap ~ | grep -v '[/~]$' | grep '^\..*'` )
- set lcl_files = ( $lcl_files .icons )
- echo "FILES = (" >> $distFile
- foreach file ( $lcl_files )
- echo " $file" >> $distFile
- end
- echo " )" >> $distFile
-
- #-----
- # Scan through the files in the directory on this host
- # and compare the creation time with the files on the
- # other host. If the file doesn't exist or is older on
- # the other host, copy it over.
- #
-
- echo "SUBFILES = (" >> $distFile
- foreach dir ( $dirs )
- set files = ( `/bin/ls -Ap ~/$dir | grep -v '[/~]$'` )
- foreach file ( $files )
- if ( "$dir" == "emacs") then
- if ( "$file:e" != "el" && "$file:e" != "elc" ) continue
- endif
- echo " $dir/$file" >> $distFile
- end
- end
- echo " )" >> $distFile
-
- #-----
- # Get executables to copy.
- # f1 = COFF executables
- # f2 = ELF executables
- # f3 = Anything else
- #
-
- set f1 = ()
- set f2 = ()
- set f3 = ()
- set files = ( `/bin/ls -Ap ~/bin | grep -v '[/~]$'` )
- foreach file ( $files )
- set f = `file ~/bin/$file`
- if ( "$f[2]" == "ELF" ) then
- set f2 = ( $f2 ~/bin/$file )
- else if ( "$f[2]" == "MIPSEB" && "$f[3]" == "COFF" ) then
- set f1 = ( $f1 ~/bin/$file )
- else
- set f3 = ( $f3 ~/bin/$file )
- endif
- end
-
- if ( $#f1 > 0 ) then
- echo "COFFFILES = (" >> $distFile
- foreach f ( $f1 )
- echo " $f" >> $distFile
- end
- echo " )" >> $distFile
- endif
-
- if ( $#f2 > 0 ) then
- echo "ELFFILES = (" >> $distFile
- foreach f ( $f2 )
- echo " $f" >> $distFile
- end
- echo " )" >> $distFile
- endif
-
- if ( $#f3 > 0 ) then
- echo "OTHFILES = (" >> $distFile
- foreach f ( $f3 )
- echo " $f" >> $distFile
- end
- echo " )" >> $distFile
- endif
-
- set noglob
- echo "BADFILES = (" >> $distFile
- foreach file ( $bad_files )
- echo " $file" >> $distFile
- end
- echo " )" >> $distFile
-
- echo "NTOTOFILES = (" >> $distFile
- foreach file ( $non_toto )
- echo " $file" >> $distFile
- end
- echo " )" >> $distFile
-
- echo "TOTOFILES = (" >> $distFile
- foreach file ( $toto_only )
- echo " $file" >> $distFile
- end
- echo " )" >> $distFile
- unset noglob
-
- if ( $#old_hosts > 0 ) then
- echo '${FILES} -> ${OLDHOSTS}' >> $distFile
- echo '\texcept_pat ${BADFILES};' >> $distFile
- echo '\texcept_pat ${TOTOFILES};' >> $distFile
- echo "" >> $distFile
- echo '${SUBFILES} -> ${OLDHOSTS}' >> $distFile
- echo '\texcept_pat ${BADFILES};' >> $distFile
- echo '\texcept_pat ${TOTOFILES};' >> $distFile
- echo "" >> $distFile
- echo '${COFFFILES} -> ${OLDHOSTS}' >> $distFile
- echo '\texcept_pat ${BADFILES};' >> $distFile
- echo '\texcept_pat ${TOTOFILES};' >> $distFile
- echo "" >> $distFile
- echo '${OTHFILES} -> ${OLDHOSTS}' >> $distFile
- echo '\texcept_pat ${BADFILES};' >> $distFile
- echo '\texcept_pat ${TOTOFILES};' >> $distFile
- echo "" >> $distFile
- endif
-
- if ( $#toto_hosts > 0 ) then
- echo '${FILES} -> ${TOTOHOSTS}' >> $distFile
- echo '\texcept_pat ${BADFILES};' >> $distFile
- echo '\texcept_pat ${NTOTOFILES};' >> $distFile
- echo "" >> $distFile
- echo '${SUBFILES} -> ${TOTOHOSTS}' >> $distFile
- echo '\texcept_pat ${BADFILES};' >> $distFile
- echo '\texcept_pat ${NTOTOFILES};' >> $distFile
- echo "" >> $distFile
- echo '${COFFFILES} -> ${TOTOHOSTS}' >> $distFile
- echo '\texcept_pat ${BADFILES};' >> $distFile
- echo '\texcept_pat ${NTOTOFILES};' >> $distFile
- echo "" >> $distFile
- echo '${ELFFILES} -> ${TOTOHOSTS}' >> $distFile
- echo '\texcept_pat ${BADFILES};' >> $distFile
- echo '\texcept_pat ${NTOTOFILES};' >> $distFile
- echo "" >> $distFile
- echo '${OTHFILES} -> ${TOTOHOSTS}' >> $distFile
- echo '\texcept_pat ${BADFILES};' >> $distFile
- echo '\texcept_pat ${NTOTOFILES};' >> $distFile
- echo "" >> $distFile
- endif
-
- if ( $#new_hosts > 0 ) then
- echo '${FILES} -> ${NEWHOSTS}' >> $distFile
- echo '\texcept_pat ${BADFILES};' >> $distFile
- echo "" >> $distFile
- echo '${SUBFILES} -> ${NEWHOSTS}' >> $distFile
- echo '\texcept_pat ${BADFILES};' >> $distFile
- echo "" >> $distFile
- echo '${COFFFILES} -> ${NEWHOSTS}' >> $distFile
- echo '\texcept_pat ${BADFILES};' >> $distFile
- echo "" >> $distFile
- echo '${ELFFILES} -> ${NEWHOSTS}' >> $distFile
- echo '\texcept_pat ${BADFILES};' >> $distFile
- echo "" >> $distFile
- echo '${OTHFILES} -> ${NEWHOSTS}' >> $distFile
- echo '\texcept_pat ${BADFILES};' >> $distFile
- echo "" >> $distFile
- endif
-
- rdist -y -f $distFile | grep -v '^Warning'
- # rdist -y -f $distFile
-