#!/sbin/sh
#ident "%W% %G%"


pak_registered(){
	LMFCK=/usr/sbin/lmfck
	VERSION=${VERSION=" "}
	DATE=${DATE=" "}
 
	if $LMFCK KWS-BASE   KUBOTA "$VERSION" "$DATE" || \
           $LMFCK KWS-DOREDEV KUBOTA "$VERSION" "$DATE" || \
           $LMFCK KWS-PICKER KUBOTA "$VERSION" "$DATE"
	then
		OKAY=okay
	else
		if [ "$1" != "menu" ]
		then
			echo "No license was found for this product"
		fi
		exit 1
	fi
}


Main()
{
	case $ACT in
	C)
		case $1 in
		INSTALL)
			pak_registered
                        ;;
                DELETE)
                        ;;
		esac
		;;
	M)
		pak_registered menu
		;;
	V)
		pak_registered
		;;
	esac

# install the man pages

SUBSET=KWSDOREMN
WHATISDIR=/usr/share/man
WHATIS=$WHATISDIR/whatis

if [ ! "$CHECK_SYNTAX" ]; then
  case "$ACT" in
    POST_L)

      # If /usr/share/man/whatis exists, concatenate it with this
      # subset's SUBSET.whatis file, and sort unique the result.  If
      # /usr/share/man/whatis does not exist, copy only this subset's
      # SUBSET.whatis file onto /usr/share/man/whatis.

      if [ -f $WHATISDIR/.$SUBSET.whatis ]; then
        if [ -f $WHATIS ]; then
          sort -u $WHATIS $WHATISDIR/.$SUBSET.whatis > $WHATIS.tmp
          mv $WHATIS.tmp $WHATIS
        else
          cp $WHATISDIR/.$SUBSET.whatis $WHATIS
        fi
      else
	echo "
        $WHATISDIR/.$SUBSET.whatis does not exist.
        "
      fi
	
      ;;
    PRE_D)
      # If this subset's SUBSET.whatis file exists, concatenate it with
      # /usr/share/man/whatis, then sort | unique to retain only the
      # unique entries.  If the SUBSET.whatis file does not exist, just
      # display an error message.

      if [ -f $WHATISDIR/.$SUBSET.whatis ]; then
        sort $WHATISDIR/.$SUBSET.whatis $WHATIS > $WHATIS.tmp
        uniq -u $WHATIS.tmp > $WHATIS
        rm -f $WHATIS.tmp
      else
        echo "
        Cannot update the whatis database automatically.  Run \"catman -w\"
        to refresh the whatis database.
        "
      fi
      ;;
  esac
fi

	return 0
}

[ "$CHECK_SYNTAX" ] || Main $*

