#!/bin/sh

TEXMF=/usr/share/texmf
ATEXMF=/usr/share/texmf
VTM=/var/lib/texmf
formats=$VTM/web2c
#append_db=$TEXMF/web2c/mktexupd
texmfcnf=/etc/texmf/texmf.cnf
ajtexpath='TEXINPUTS.ajtex = .;$ATEXMF/ajtex//;$TEXMF/tex/{latex209,generic,}//'
ajlatexpath='TEXINPUTS.ajlatex	= .;$ATEXMF/ajtex//;$TEXMF/tex/{latex209,generic,}//'

makeformat()
{
    FMT=$1
    if [ -x /usr/bin/ptex ]; then
	TEXINPUTS="$ATEXMF/ajtex//;$TEXMF/tex/{latex209,generic,}//" fmtutil-sys --cnffile \
	/etc/texmf/fmtutil-ajtex.cnf --byfmt $FMT
    else
	echo "ptex command does NOT exist!!!"
    fi
}

init_ajtex_fmt() {
	test -f $ATEXMF/ajtex/config/ajtex.ini && makeformat ajtex
}

init_ajlatex_fmt() {
	test -f $ATEXMF/ajtex/config/ajlatex.ini && makeformat ajlatex
}

init_tex_formats() {
	init_ajtex_fmt
	init_ajlatex_fmt
}

case $1 in
init|formats)
    init_tex_formats ;
	;;
ajtex)
    init_ajtex_fmt ;
	 ;;
ajlatex)
    init_ajlatex_fmt ;
	 ;;
*)	echo "Usage $0 [ formats | ajtex | ajlatex ]" ;
	exit 1
esac

