#bin/sh
DIR=`pwd`
unzip  -o  $DIR/upgrade.zip
echo "unzip  zip source  successed"
\cp  $DIR/server/*  /opt/epcloud/server/
\cp  $DIR/vmMoveOnLocalStorage/*  /var/opt/epcloud/server/store/jobs/vmMoveOnLocalStorage
systemctl stop svc-dashboard
\cp  $DIR/dashboard/*  /var/opt/apache-tomcat-8.0.28/webapps/svc-dashboard/WEB-INF/classes/com/starit/vcenter/modules/resmanage/service/
systemctl start svc-dashboard
hostname=`hostname`
allinone=`ls /usr/sbin/ | grep svc_standalone`
if [ "$allinone" == "svc_standalone.sh" ];then
	systemctl restart epcloud-server
	echo "restart epcloud-server  successed"
else
	pcs=`pcs status | grep "Started $hostname"`
	if [ "$pcs" == "" ];then
    	echo "update epcloud-server  successed"
	else
    	systemctl restart epcloud-server
    	echo "restart epcloud-server  successed"
	fi
fi