#!/bin/bash

# $Id: postInstallCyteSeer,v 1.1.2.3 2010-01-19 21:35:53 esuparno Exp $

####################################################################################
#
# Program Name: postInstallCyteSeer
# Engineer:	Erwin Suparno
# Date:		7/15/2009
#
# Description:	This program is to do a post install configuration of CyteSeer program
#
####################################################################################

### source /etc/init.d/functions for [OK] & [FAILED] functions
. /etc/init.d/functions

# the CyteSeer Program
PROGNAME="CyteSeer"
PROGHOME="/usr/local/$PROGNAME"
CYTESEER="\"$PROGHOME/$PROGNAME\""

# root java userPrefs
ROOT_JAVA_USERPREFS="/root/.java/.userPrefs"

rootCheck() {
########################
####	rootCheck
### purpose: all scripts in the here must be run by root.  this function will verify the user making the call is root
##  created by: a2Peterson 02/20/2008
#   updated by:
########################
if [ "`whoami`" != "root" ]; then
	echo
	echo "You must be root to run this script..."
	echo
	exit 1
fi
}

checkCyteSeerExist() {
#######################################
####    checkCyteSeerExist 
### purpose: checks if CyteSeer is installed 
##  created by: esuparno 07/15/2009
#   updated by:
############################
if [ ! -e "$PROGHOME/jilaunch" ] && [ ! -d "$ROOT_JAVA_USERPREFS/com" ] && [ ! -d "$ROOT_JAVA_USERPREFS/com/dreic/security" ]; then 
        echo "CyteSeer is not found, please install it as root (superuser) and re-run this program\!" && echo_failure
        echo
        exit 1
fi
}

createCyteSeerSymLink() {
#######################################
####    createCyteSeerSymLink
### purpose: createCyteSeerSymLink
##  created by: esuparno 07/15/2009
#   updated by:
############################
echo "    *********"
echo "Creating CyteSeer Symbolic Link..."
ln -sf $PROGHOME/CyteSeer\ * $PROGHOME/CyteSeer && echo_success || echo_failure
}


################
# MAIN
################
rootCheck
checkCyteSeerExist
createCyteSeerSymLink
# EOF
