#!/bin/bash
# $Header: /cvs/WebShield/wsrc/files/mgmt/Attic/install_epo_agent,v 1.2 2001/06/07 15:43:08 ebaulk Exp $
#
# (C) Copyright Network Associates Inc. 2001
#
if [ -f $NETAWSS/.profile.vars ]; then
    . $NETAWSS/.profile.vars
else
    . /var/NAIENV/.profile.vars
fi
[[ "$PATH" == "$wsPATH":* || -z "$wsPATH" ]] || PATH=$wsPATH:$PATH

LOGFILE=/tmp/epo_install.log

exec >> ${LOGFILE} 2>&1 

echo -e "\n------- Start `date`"  
echo User has requested that the ePolicy Orchestrator Agent be installed

# Make sure there is a file with something in it
if [[ -z "$1" || ! -s "$1" ]]; then
    echo file $1 not found or empty >&2
    exit 1
fi

# Make the file executable
chmod +x $1

# Be sure to run the right file
if [[ "$1" == /* ]]; then
    runfile=$1
else
    runfile=./$1
fi

# Execute the file
$runfile
# store the result of the exec
execResult=$?

# restart the proxies to allow the eventDispatcher to access
# the event interface added by the agent
if [[ $execResult -eq 0 ]]; then
echo Agent Install succeeded. Restarting proxies
    proxy-restart
else
echo The Agent Install failed. The return code was $execResult
fi

echo "Finished install of ePolicy Orchestrator Agent" 
echo -e "------- End `date`\n"
exit $execResult
