#! /bin/sh

#. /usr/local/bcnu/etc/bcnuenv
. $BCNUHOME/agent/agent_head

{

set -x
eval $BCNUPARAM

MYNAME=`uname -n`

$BCNUHOME/scripts/upgrade_bcnuv2 -h $BCNUHOME -s -a

cp $BCNUHOME/etc/bcnud_server.distrib  $BCNUHOME/etc/bcnud_server
echo "Retrieving agent file from : $BCNUHOST"
if $BCNU -a get -f /clients/agents.$MYNAME $BCNUHOST >$BCNUHOME/etc/agents
        then
                echo "Client agent retrieved OK"
else
                echo "Agent Retrieve Failed - Upgrade aborted"
                exit
fi

echo "Auto Upgrade process complete.... starting bcnu"

LOGNAME=$BCNUUSER
export LOGNAME

$BCNUHOME/etc/bcnud_server start
} >/tmp/bcnuupgrade.$$.log 2>&1
