#! /bin/sh
# @(#)install_ctable.sh 1.2 91/09/14
#
#         Copyright (C) 1991  Sun Microsystems, Inc
#                   All rights reserved.
#           Notice of copyright on this source code
#           product does not indicate publication.
# 
# RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by 
# the U.S. Government is subject to restrictions as set forth 
# in subparagraph (c)(1)(ii) of the Rights in Technical Data
# and Computer Software Clause at DFARS 252.227-7013 (Oct. 1988) 
# and FAR 52.227-19 (c) (June 1987).
#
# Sun Microsystems, Inc.
# 2550 Garcia Avenue
# Mountain View, California 94043
#

#
# This is the script to put the 'fixed' /usr/share/lib/locale/LC_CTYPE/C
# file in place. See bugid 1041074/1052849 for details why this is necessary.
# The fix is necessary for SunOS4.1 and SunOS4.1.1
#
# The old .../C file is moved to .../C.broken
#
# This script assumes that OPENWINHOME is set to where OpenWindows is
# installed
#
# This script must be run as superuser
#

PATH="/bin:/usr/ucb:/usr/bin:/etc:/usr/etc"
export PATH

if [ "root" != `whoami` ]
then
	echo "Fix failed - must be run in super-user mode."
	exit 1
fi

if [ "" = "$OPENWINHOME" ]
then
	echo 'Fix failed because $OPENWINHOME is undefined.'
	echo 'Please set $OPENWINHOME and rerun this script.'
	exit 1
fi

if [ ! -d "$OPENWINHOME" ]
then
	echo 'Fix failed because $OPENWINHOME is set to'
	echo \""$OPENWINHOME"\" 'which is not a directory.'
	echo 'Please check $OPENWINHOME and and rerun this script.'
	exit 1
fi

if [ ! -x "$OPENWINHOME/lib/C.ct" ]
then
	echo 'Fix failed because OpenWindows has not been properly'
	echo "installed into $OPENWINHOME"
	echo 'Please check this directory and $OPENWINHOME and rerun'
	echo 'this script.'
	exit 1
fi

echo "*************** Installing fixed /usr/share/lib/locale/LC_CTYPE/C file"
echo

echo "moving /usr/share/lib/locale/LC_CTYPE/C to /usr/share/lib/locale/LC_CTYPE/C.broken"
echo

# save old C file

mv /usr/share/lib/locale/LC_CTYPE/C /usr/share/lib/locale/LC_CTYPE/C.broken

cd /usr/share/lib/locale/LC_CTYPE

echo 'generating new /usr/share/lib/locale/LC_CTYPE/C'
echo

# generate the fixed version of /usr/share/lib/locale/LC_CTYPE/C

chrtbl $OPENWINHOME/lib/C.ct
chmod 644 /usr/share/lib/locale/LC_CTYPE/C

echo "*************** Done with installation of fix"

exit 0
