#!/bin/ksh -x
### Usage:	install_locales <boot image absolute path>
### Parameters:	$1 = if setup for disk0 or cd0
###             $2 = boot image directory (Ex: /export2/s26_sparc)

### Vars
LOC=$1
BOOTIMAGE=$2
ARCH=`uname -p`
SRC=`pwd`

### Zip info
if [ $ARCH = i386 ];then
	ZIP=/opt/info-zip/zip22_x86/zip
else
	ZIP=/opt/info-zip/zip22/zip
fi

### Make sure we are root
if [ `/usr/ucb/whoami` != "root" ]; then
	echo "You Must be root."
	exit 1
fi

### Figure out which path to go
case $LOC in
	cd0) ;;
	disk0) ;;
	*)
		echo 1st parameter must be cd0 or disk0;
		echo "Usage: install_locales [format (cd0/disk0)] [Solaris Boot Image]";
		exit 1
esac	


if [ $LOC = disk0 ]; then
	echo "Setting up disk0 locales"
else
	echo "Setting up cd0 locales"
	if [ ! -d $BOOTIMAGE/webstart ]; then
		echo "No webstart directory - creating one"
		mkdir $BOOTIMAGE/webstart
		/usr/bin/chmod 775 $BOOTIMAGE/webstart
	fi
	
	if [ ! -d $BOOTIMAGE/webstart/lib ]; then
		echo "No lib directory - creating one"
		mkdir $BOOTIMAGE/webstart/lib
		/usr/bin/chmod 775 $BOOTIMAGE/webstart/lib
	fi
	
	if [ ! -d $BOOTIMAGE/webstart/lib/locale ]; then
		echo "No locale directory - creating one"
		mkdir $BOOTIMAGE/webstart/lib/locale
		/usr/bin/chmod 775 $BOOTIMAGE/webstart/lib/locale
	fi
	
	### Start the process...
	cd $SRC/locale/$LOC/$ARCH
	find . -name SCCS -prune -o -print | cpio -pdum  $BOOTIMAGE/webstart/lib/locale/
fi

