#!/bin/sh

set -a

#
#   This script creates or removes nls links for CDE 
#   environment variable NEWDIR is supposed 
#   to be set up by caller
#
#  If first parameter is ADD/add the links are added
#  otherwise they will be removed
#

if [ "$NEWDIR" = "" ]
then
  NEWDIR=/opt/hpxt/enware2/xthome
fi

#   Make links for 10.0 style locale names
#


DEST=`echo $NEWDIR | sed -e 's!^/usr/tftpdir!!' -e 's!^/tftpboot!!'`
NLSDEST=$DEST/nls
BINDEST=$DEST/bin
XFONTDEST=$DEST/dt/usr/config/xfonts
APPDEFDEST=$DEST/dt/usr/app-defaults
JAPAPPDEFDEST=$DEST/lib
APPCONFIG=$DEST/dt/usr/appconfig/types
DTCONFIG=$DEST/dt/usr/config
NLSMSG=$DEST/dt/usr/lib/nls/msg
JAPNLS=$DEST/nls/japanese

# directories
cd ${NLSDEST}
rm -f ja_JP.SJIS
rm -f ja_JP.eucJP

if [ "$1" = "ADD" -o "$1" = "add" ]
then
  ln -s japanese         ja_JP.SJIS
  ln -s japanese/euc     ja_JP.eucJP
fi

# files
cd ${NLSDEST}/Xhp
rm -f ja_JP.SJIS
rm -f ja_JP.eucJP

if [ "$1" = "ADD" -o "$1" = "add" ]
then
  ln -s japanese      ja_JP.SJIS
  ln -s jeuc          ja_JP.eucJP
fi

# fonts
cd ${XFONTDEST}
rm -f ja_JP.SJIS
rm -f ja_JP.eucJP

if [ "$1" = "ADD" -o "$1" = "add" ]
then
  ln -s japanese ja_JP.SJIS 
  ln -s japanese.euc ja_JP.eucJP
fi

# app-defaults directories
cd ${APPDEFDEST}
rm -f ja_JP.SJIS
rm -f ja_JP.eucJP

if [ "$1" = "ADD" -o "$1" = "add" ]
then
  ln -s japanese ja_JP.SJIS 
  ln -s japanese.euc ja_JP.eucJP
fi

# app-defaults directories
cd ${JAPAPPDEFDEST}
rm -f ja_JP.SJIS
rm -f ja_JP.eucJP

if [ "$1" = "ADD" -o "$1" = "add" ]
then
  ln -s japanese      ja_JP.SJIS
  ln -s japanese.euc  ja_JP.eucJP
fi

# appconfig directories
cd ${APPCONFIG}
rm -f ja_JP.SJIS
rm -f ja_JP.eucJP

if [ "$1" = "ADD" -o "$1" = "add" ]
then
  ln -s japanese      ja_JP.SJIS
  ln -s japanese.euc  ja_JP.eucJP
fi

# dtconfig directories
cd ${DTCONFIG}
rm -f ja_JP.SJIS
rm -f ja_JP.eucJP

if [ "$1" = "ADD" -o "$1" = "add" ]
then
  ln -s japanese      ja_JP.SJIS
  ln -s japanese.euc  ja_JP.eucJP
fi

# msg directories
cd ${NLSMSG}
rm -f ja_JP.SJIS
rm -f ja_JP.eucJP

if [ "$1" = "ADD" -o "$1" = "add" ]
then
  ln -s japanese      ja_JP.SJIS
  ln -s japanese.euc  ja_JP.eucJP
fi


# Japanese dtwmlite message catalogs
cd $JAPNLS
rm -f dtwm.cat
rm -f euc/dtwm.cat

if [ "$1" = "ADD" -o "$1" = "add" ]
then
  ln -s ../../dt/usr/lib/nls/msg/ja_JP.SJIS/dtwm.cat dtwm.cat
  cd euc
  ln -s ../../../dt/usr/lib/nls/msg/ja_JP.eucJP/dtwm.cat dtwm.cat
fi



exit 0
