#!/bin/csh -fe
# $Disclaimer: This software is part of version 7.2 of the 
# Andrew User Interface System and is the 
# property of IBM, Carnegie Mellon University, 
# and the other copyright holders.  The source 
# code of this version is for the sole use of 
# members of the Andrew Consortium with 
# memberships extending into calendar year 
# 1994.  This source code is not to be distributed 
# to non-members of the consortium nor beyond 
# a fifty-mile radius from the membership address.  
# Binary object code compiled or derived from 
# these sources is not to be distributed to non-
# members.  Members may have additional 
# distribution rights granted by prior written 
# permission of Carnegie Mellon University.
# 
# IBM, CARNEGIE MELLON UNIVERSITY, 
# AND THE OTHER COPYRIGHT HOLDERS
#  DISCLAIM ALL WARRANTIES WITH 
# REGARD TO THIS SOFTWARE, INCLUDING 
# ALL IMPLIED WARRANTIES OF MERCHANT-
# ABILITY AND FITNESS. IN 
# NO EVENT SHALL  IBM, CARNEGIE 
# MELLON UNIVERSITY, OR ANY OTHER 
# COPYRIGHT HOLDER BE LIABLE FOR 
# ANY SPECIAL, INDIRECT OR CONSE-
# QUENTIAL DAMAGES OR ANY DAMAGES 
# WHATSOEVER RESULTING FROM LOSS OF
# USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR
# OTHER TORTIOUS ACTION, ARISING OUT 
# OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#  $

set nonomatch
echo "----------------------------------------------------------------------"
echo " \
This Script will upadte console files in the following ways: \
	rename console/vopcon files to have the [new] correct \
	  extension. \
	edit the .con/.vop files to replace certain fontnames with \
	  their new fontnames. \
 \
The new extensions are now: \
	'.con' instead of '.console' or '.Console' \
	'.vop' instead of '.vopcon' or '.Vopcon' \
 \
Then known changed font names are: \
	con10 instead of console10 \
	con12 instead of console12 \
	andy120 instead of andrew120 \
	msgs10 instead of messages10 \
	msgs14 isntead of messages14 "
echo ""
echo "----------------------------------------------------------------------"
echo -n "Rename console/vopcon files to use new extension? (y/n) [y] "
set foo=$<
if ($foo != "n" && $foo != "N") then
	set CONS = `/bin/ls *.console *.Console` 
	set VOPS = `/bin/ls *.vopcon *.Vopcon`
	if ($#CONS == 0 && $#VOPS == 0) then
		echo "No files to be renamed"
	else
		echo "Begining rename"
		if ($#CONS != 0) then
			foreach i (${CONS})
				echo "## $i"
				set conname = $i:r
				mv $i ${conname}.con
			end
		endif
		if ($#VOPS != 0) then
			foreach i (${VOPS})
				echo "## $i"
				set conname = $i:r
				mv $i ${conname}.vop
			end
		endif
		echo "Done."
	endif
endif

echo "----------------------------------------------------------------------"
echo  -n "Replace outdated fontnames with new fontnames? (y/n) [y] "
set foo=$<
if ($foo != "n" && $foo != "N") then
	set CONS = `/bin/ls *.con`
	set VOPS = `/bin/ls *.vop`
	if ($#CONS == 0 && $#VOPS == 0) then
		echo "No files to edit"
	else
		echo "Replacing fontnames"
		foreach i (${CONS} ${VOPS})
			echo "### $i"
			chmod +w $i
			cat $i | sed \
				-e 's;console10;con10;g' \
				-e 's;console12;con12;g' \
				-e 's;Console10;con10;g' \
				-e 's;Console12;con12;g' \
				-e 's;CONSOLE10;con10;g' \
				-e 's;CONSOLE12;con12;g' \
				-e 's;andrew120;andy120;g' \
				-e 's;Andrew120;andy120;g' \
				-e 's;ANDREW120;andy120;g' \
				-e 's;messages10;msgs10;g' \
				-e 's;messages14;msgs15;g' \
				-e 's;Messages10;msgs10;g' \
				-e 's;Messages14;msgs15;g' \
				-e 's;MESSAGES10;msgs10;g' \
				-e 's;MESSAGES14;msgs15;g' \
				 > .foo
			mv .foo $i
			chmod -w $i
		end
		echo "Done."
	endif
	echo "----------------------------------------------------------------------"
	echo "WARNING - all .con and .vop files have now been made read-only"
	echo -n "Do you want them re-set back to read-write? (y/n) [n] "
	set foo=$<
	if ($foo == "y" || $foo == "Y") then
		echo "OK - chmod'ing them to be r/w"
		chmod +w *.con *.vop
		echo "Done."
	endif
endif

echo "All Done with Script \
	if there are any problems - please send mail to \
	Adam Stoller: \
	ghoti+@andrew.cmu.edu"

