#!/bin/sh
# Shell to generate "properties" files and others for specific locales (es_ES, etc.)
# IE JVM is looking for these files as you can check in Web Server errorlog
# Version 1.0  31/08/2001
# Author: Jesus Perez   jesus.perez@infonegocio.com
#
USAGE="$0 [locale: es_ES, en_US,etc]"
if [ "$#" -eq 0 ] 
then 
    echo "$USAGE" 
     exit 1
fi
# Where are base resources Files
BASE=/opt/tarantella/tools/ie/base
dn=/dev/null
Locale=$1
preLocale=`echo $Locale | cut -f1 -d"_" 2>$dn` 
origen=`pwd` 
make_file() {
   cp $2 $1/$3
   chmod 644 $1/$3
   chown bin:bin $1/$3
   echo "$3"
}

make_FilesOnDir () {
   cd $BASE/$1
   # Where is filelist to create ... 
   LISTA=listaFiles
   [ ! -r $LISTA ] && echo "No \"listaFiles\": Nothing to do in dir \"$1\" " && return 0
   [ ! -r DestPath ] && echo "No \"DestPath\" File to use for dir \"$1\" " && return 0 
   # Where to install Files
   DestPath=`cat DestPath 2>$dn` 
   [ ! -d $DestPath ] && echo "\"$DestPath\": No Valid PATH to use for dir \"$1\" " && return 0 
   echo "Directory: $1 ... "
   echo "Making files for $Locale ... "
   echo "In Directory PATH: $DestPath ... "
   for nom in `cat $LISTA 2>$dn` 
   do
      preName=`echo $nom | cut -f1 -d"." 2>$dn` 
      extName=`echo $nom | cut -f2 -d"." 2>$dn` 
      newFile=$preName"_"$Locale.$extName
      make_file $DestPath $nom $newFile
   
      newFile=$preName"_"$preLocale.$extName
      make_file $DestPath $nom $newFile
   done
}

cd $BASE
# where is listDirs to scann ...
ListaDirs=listaDirs
[ ! -r $ListaDirs ] && echo "No file \"listaDirs\": No Directory List on $BASE " && exit 1
echo "Checking Directories list on $BASE/$ListaDirs ... "
for nomDir in `cat $ListaDirs 2>$dn` 
do
   make_FilesOnDir $nomDir
done
cd $origen
 

