#! /bin/sh
# Configuration script for ntm-ltx? (NTeX) V1.0
# Copyright 1994, Frank Langbein
# All rights reserved.
#
# Redistributions of this script must retain the above copyright notice, 
# this condition and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

curr_dir=$(pwd)
editor=vi

cat << EOF

Configuring the ntm-ltx? packages

EOF

rm -f /usr/lib/texmf/tex/latex/cfg/lthyphen.cfg
if test -e /usr/lib/texmf/tex/latex/cfg/language.dat;then
   (cd /usr/lib/texmf/tex/latex/cfg; ln -s ./lthyphen.babel ./lthyphen.cfg)
   cat << EOF

You have installed LaTeX2e with babel. There is a file 
/usr/lib/texmf/tex/latex/cfg/language.dat which defines which
hyphenation tables are loaded into LaTeX2e. It is preconfigured with
ukenglish, usaenglish, german and swedish. If you want to change this
you have to edit this file. Please do not load more hyphenation tables
as you need since TeX's capacity is limited. I think you will get in
trouble if you load more than 4 tables, but this depends on the size of
them.

EOF
   echo -n "Do you want to edit language.dat now (with $editor) [y/n]? "
   read ANS
   if test "$ANS" = "y" -o "$ANS" = "Y"; then
      cmd="$editor /usr/lib/texmf/tex/latex/cfg/language.dat"
      echo Running $cmd
      $cmd
   fi
   echo 1
else
   (cd /usr/lib/texmf/tex/latex/cfg; ln -s ./lthyphen.latex ./lthyphen.cfg)
fi

cat << EOF

Since you have installed LaTeX2e you might also want to recreate the
LaTeX2e format file. You should do this especially if you did not install
all LaTeX2e packages or if you changed language.dat from babel.

EOF

echo -n "Do you want to do this now [y/n]? "
read ANS
if test "$ANS" = "y" -o "$ANS" = "Y"; then
   echo Rebuilding the latex format file.
   cd $curr_dir
   /usr/bin/initex latex.ltx
   chmod 0644 $curr_dir/latex.fmt
   chmod 0644 $curr_dir/latex.log
   mv -f $curr_dir/latex.fmt /usr/lib/texmf/ini/latex.fmt
   mv -f $curr_dir/latex.log /usr/lib/texmf/ini/latex.log
   rm -f $curr_dir/texsys.aux
   echo done.
fi
