#!/bin/csh -f
set hostlist=(cruncher muncher blaster)
set ruser=gish
set machtype=sgi/irix5

# List of applications that receive a .local extension on their names
set locallist=(blastp blastn blastx tblastn blast3)
set all=(${locallist} setdb pressdb pam memfile gb2fasta gt2fasta pir2fasta sp2fasta)
if ("${argv}" == "") then
	set argv=(${all})
endif

foreach x ( $argv )
	if ( -x $x ) then
		set copyname=/usr/ncbi/bin/$x
		set message=""
		foreach y ( ${locallist} )
			if ($x == $y) then
				set copyname=/usr/ncbi/bin/${x}.local
				set message=" as ${x}.local"
				break
			endif
		end
		set newcopy=${copyname}.new
		set oldcopy=${copyname}.old

		echo Installing ${x}${message}

		foreach h ( ${hostlist} )
			rcp $x ${ruser}@${h}:${newcopy}
			if (${status} != 0) then
				continue;
			endif
			rsh ${h} -l ${ruser} -n /bin/mv -f ${copyname} ${oldcopy} \; /bin/mv -f ${newcopy} ${copyname} \; /bin/rm -f ${oldcopy}
		end

		rcp $x ${ruser}@ncbi:\~ftp/blast/executables/${machtype}/$x
	else
		echo "${x} IS NOT EXECUTABLE"
	endif
end

