#!/bin/sh
#
# A script to install the vga font into XFS, probably needs to run as root
#

# From: Brandon Ehle <behle@pipedreaminteractive.com>

# Find the vga font
if test ! -f "vga.pcf"; then
  if test ! -f "../misc/vga.pcf"; then
    if test ! -f "misc/vga.pcf"; then
      echo Font vga.pcf is missing!
      exit
    else
      VGAFONT=misc/vga.pcf
    fi
  else
    VGAFONT=../misc/vga.pcf
  fi
else
  VGAFONT=vga.pcf
fi

# Check for XFS
if test `which chkfontpath`; then
  if test ! -f "/var/run/xfs.pid"; then
    echo XFS installed but not running!
    printf "Do you want to install into XFS anyway [Yn]? "
    read YN
    : $(YN=y)
    case $YN in
	[Yy]) USEXFS=1;;
    esac
  else
    echo XFS installed and running
    USEXFS=1
  fi
else
  echo
  echo The chkfontpath utility was not found in the path!
  echo Verify that chkfontpath exists and try again
  echo
  echo If your X Server is not using XFS,
  echo you may need to install fonts manually into /etc/X11/XF86Config
  exit
fi

# Install the font in /usr/local/share/fonts/bitmap/ and register with XFS
if test $USEXFS; then
  echo Install fonts into XFS
  mkdir -p /usr/local/share/fonts/bitmap/
  install $VGAFONT /usr/local/share/fonts/bitmap/
  chkfontpath --add /usr/local/share/fonts/bitmap/
else
  echo Did not install fonts
fi
