#!/bin/rc
# Push out changes to other windows hosts

####### Hosts to synchronise
#	  		balthazar       mordechai       bill
hostlist=(lb-slp-en-grp01 se-slp-en-04472 vm-slp-en-conv1)

# syntax for remote hosts is different.
# c:/plan9 becomes \\host/c/plan9
rem9=`{echo $plan9 | sed 's/://'}

# Datestamp the release
date > c:/plan9/Release

exist=()			# cache of dirs known to exist

fn synch {
	file=$1

	for(host in $hostlist){

		dir=`{basename -d \\$host/$rem9/$file}
		if(! ~ $"dir $exist){
			if(! test -d $"dir)
				mkdir $"dir
			exist=($exist $"dir)
		}

		if(test $plan9/$file -nt \\$host/$rem9/$file)
			cp $plan9/$file \\$host/$rem9/$file
	}
}

cd $plan9

# selected files in $plan9 directory
for(f in push Release Notes install.bat)
	synch $f

# directories whos contents should be synchronised
dirlist=(rc/bin rc/lib)
dirlist=($dirlist $objtype/bin $objtype/bin/service)
dirlist=($dirlist $objtype/bin/mswin $objtype/bin/auth) 

for(d in $dirlist)
	for(f in $d/*)
		if(! ~ $f */_* && test -f $f)
			synch $f 

