#!/bin/sh
#
# install_KDE - install treeps to/for KDE
#
# Assume the CWD is in the desktop dir and userid is root.

# Use KDEDIR if defined, otherwise try the usual place - /opt/kde
# If that fails try checking to see if the KDE files are in /usr/share.

if [ ! -z "$KDEDIR" ]
then
    KDE_ROOT="$KDEDIR"
else
  if [ -d "/opt/kde" ]
  then
    KDE_ROOT=/opt/kde
  else
    # On some Red Hat the kde files go into /usr/share by default.
    if [ -d "/usr/share/applnk" ]
    then
        KDE_ROOT=/usr
    fi
  fi
fi


if [ ! -d "$KDE_ROOT" ]
then
  echo ""
  echo "NOTE: Can't find KDE root - checked in $KDE_ROOT"
  echo "You can install on KDE later by running "
  echo "./Setup -d from the treeps lib directory"
  exit 0
fi

out "Installing KDE Files "

ICON_ROOT=icons

D=share/applnk/System

installFile -m 644 desktop/KDE/$D/ktreeps.kdelnk    $KDE_ROOT/$D/ktreeps.kdelnk


D=share/icons/mini

installFile -m 644 desktop/KDE/$D/treeps.xpm    $KDE_ROOT/$D/treeps.xpm

# Note keep this after the above so the uninstall order is correct.

D=share/icons

installFile -m 644 desktop/KDE/$D/treeps.xpm    $KDE_ROOT/$D/treeps.xpm


D_OLD=share/doc/HTML/C/ktreeps

D=share/doc/HTML/en/ktreeps

installDir -m 755  $KDE_ROOT/$D

installFile -m 644 desktop/KDE/$D/index.html      $KDE_ROOT/$D/index.html
installFile -m 644 desktop/KDE/$D/index-1.html    $KDE_ROOT/$D/index-1.html
installFile -m 644 desktop/KDE/$D/index-2.html    $KDE_ROOT/$D/index-2.html
installFile -m 644 desktop/KDE/$D/index-3.html    $KDE_ROOT/$D/index-3.html
installFile -m 644 desktop/KDE/$D/index-4.html    $KDE_ROOT/$D/index-4.html
installFile -m 644 desktop/KDE/$D/index-5.html    $KDE_ROOT/$D/index-5.html

# Don't know if this is ok to do or not...

installLink  $KDE_ROOT/$D $KDE_ROOT/$D_OLD

installFile -m 644 desktop/KDE/$D/logotp3.gif $KDE_ROOT/$D/logotp3.gif

# Copy/link docs

D=bin

# On Redhat 6.0 the bin dir does not exist by default, so we don't
# bother to create the dir and link just for treeps.

if [ -d "$KDE_ROOT/$D" ]
then
    installLink $BINDIR/treeps $KDE_ROOT/$D/ktreeps
fi
