#!/bin/sh

# Author: Blake, Kuo-Lien Huang
# License: GPL
# Description:
#   bootcd only copy the "directory" in /var.ro to ram2.cpio.gz
#   we have to link the /var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType/*
#   to /var.ro/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType/* to make
#   Deforma work
#   we do the same for /var/lib/defoma/x-ttcidfont-conf.d/dirs/CID/*
#
#   2003-06-18:
#   register bkai00mp, bkmi00mp in defoma (Debian Font Manager) when 
#   the first time DRBL nodes bootup.
#
case $1 in
  "start")
    if [ -e /var.ro ]; then
	  # TrueType
	  VAR_TTFPATH="lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
	  echo "$VAR_TTFPATH"
	  for file in `ls /var.ro/$VAR_TTFPATH`
	  do
	    ln -s /var.ro/$VAR_TTFPATH/$file /var/$VAR_TTFPATH/$file
	  done
	  # CID
	  VAR_CIDPATH="lib/defoma/x-ttcidfont-conf.d/dirs/CID"
	  for file in `ls /var.ro/$VAR_CIDPATH`
	  do
	    ln -s /var.ro/$VAR_CIDPATH/$file /var/$VAR_CIDPATH/$file
	  done
    else
      # register bkai00mp, bkmi00mp in defoma (Debian Font Manager) when 
      # the first time DRBL nodes bootup.
      if [ -d /etc/diskless-host -a ! -f /etc/diskless-host/defoma ]; then
        /usr/bin/defoma-font register-all /etc/defoma/hints/ttf-arphic-bkai00mp.hints
        /usr/bin/defoma-font register-all /etc/defoma/hints/ttf-arphic-bsmi00lp.hints
        # Blake,2004/02/25, cmap-adobe-cns1 cmap-adobe-gb1
        /usr/bin/defoma-font register-all /etc/defoma/hints/cmap-adobe-cns1.ext.hints
        /usr/bin/defoma-font register-all /etc/defoma/hints/cmap-adobe-cns1.std.hints
        /usr/bin/defoma-font register-all /etc/defoma/hints/cmap-adobe-gb1.ext.hints
        /usr/bin/defoma-font register-all /etc/defoma/hints/cmap-adobe-gb1.std.hints
        /usr/bin/defoma-font register-all /etc/defoma/hints/gs-cjk-resource.hints
        /usr/bin/defoma-font register-all /etc/defoma/hints/gsfonts.hints
        # Blake,2004/03/29, wangfont
        /usr/bin/defoma-font register-all /etc/defoma/hints/ttf-wangfont.hints

        /usr/bin/defoma-reconfigure
        touch /etc/diskless-host/defoma
      fi 
    fi
    ;;
  "*")
    ;;
esac
