#! /bin/sh

#========================================================================
# /bin/sh
# Trivial install script for X11-QMR
#
# @(#)qmr.install  $Revision: 1.5 $   $Date: 1994/09/29 14:50:19 $
#========================================================================

#========================================================================
# Global Vars
#========================================================================

LIBD="/usr/lib/X11"

prompt="Are you logged in as root y or n ?"

#========================================================================
# GET_YESNO -- Get a y or n reply to the prompt var
#========================================================================

get_yesno () {
while [ true ] ;
do
    echo -n "$prompt"
    read $junk yesno

    if [ "$yesno" = "" ]
    then
	echo "Please give a response, not just CR !!"
	continue
    fi

    if [ $yesno = y ]
    then
	break
    fi

    if [ $yesno = n ]
    then
	break
    fi

    echo "Please answer y or n !!!"
done
}

# Start the installation..

# First test if /usr/lib/X11 exists

if [ -d /usr/lib/X11/uid ]
then
    echo "Good, /usr/lib/X11 found"
else
    echo "Creating symbolic link for /usr/lib/X11"
    ln -s /usr/X386/lib/X11 /usr/lib/X11
fi

# Next test if there are pc fonts, if not add the lines to the fontdir

echo "Installing X11-QMR, to do this you must be root."
echo
get_yesno
if [ $yesno = n ]
    then
	echo "Instalation stopped, log in as root then do it again"
	exit 1
fi

echo
if [ -f ${LIBD}/fonts/misc/pc8x8.pcf.Z ]
    then
	echo "Pc fonts are already present.."
	echo
    else
	echo "Adding PC-Font descriptions to misc/fonts.dir"
	echo "pc8x8.pcf.Z pc8x8" >> ${LIBD}/fonts/misc/fonts.dir
	echo "pc8x14.pcf.Z pc8x14" >> ${LIBD}/fonts/misc/fonts.dir
	echo "pc8x16.pcf.Z pc8x16" >> ${LIBD}/fonts/misc/fonts.dir

        echo "Copying the fonts.."
        cp pc8x8.pcf.Z ${LIBD}/fonts/misc
        cp pc8x14.pcf.Z ${LIBD}/fonts/misc
        cp pc8x16.pcf.Z ${LIBD}/fonts/misc

fi

echo

if [ -d /usr/lib/X11/uid ]
    then
	cp qmr.uid /usr/lib/X11/uid
    else
	echo "Creating UID dir.."
	mkdir /usr/lib/X11/uid
	cp qmr.uid /usr/lib/X11/uid
fi

echo "Copying the app-defaults.."
cp X11-QMR.app-defaults /usr/lib/X11/app-defaults/X11-QMR

echo "Copying the man page.."
cp qmr.8 /usr/man/man8/qmr.8

echo "Copying the Ansi View pager"
cp aview /usr/local/bin/aview

if [ -f /usr/lib/libXm.so.1.2.4 ]
    then
	echo "I found Motif 1.2.4, installing dynamic version"
	echo
	cp qmr.dynaic /usr/local/bin/qmr
    else
	echo "Motif 1.2.4 Not found, installing static version"
	cp qmr /usr/local/bin/qmr
fi

echo "Basic installation done...."
echo

echo 
echo If you have installed Ver 1.2 over version 1.1, please edit your
echo configuration file as the format has changed.
echo
echo Also please remove any .rep files in ~/QMR/UP Failure to do this
echo will result in the BBS getting the old packets only.
echo
echo "X11-QMR has been installed. Do man on qmr for further details"
echo
