#!/bin/sh
date=`date +%Y-%m-%d`
gengpwd='/root/openstackinstall/update'
pypwd='/usr/lib/python2.7/site-packages'

novafile='nova'
cinderfile='cinder'
neutronfile='neutron'
glancefile='glance_store'
centecfile='neutron/plugins/centec'

if [ ! -d $gengpwd/$date ];then
        mkdir -p $gengpwd/$date
fi

echo "wget soft"
cd $gengpwd/$date
#wget ftp://builder:dLoadAtOpenStack@125.208.28.24/build/Release/v1.0/2014.4.1/cinder-chinac.tar.gz
#wget ftp://builder:dLoadAtOpenStack@125.208.28.24/build/Release/v1.0/2014.4.1/glance_store-chinac.tar.gz
#wget ftp://builder:dLoadAtOpenStack@125.208.28.24/build/Release/v1.0/2014.4.1/neutron-chinac.tar.gz
wget ftp://builder:dLoadAtOpenStack@125.208.28.24/build/Release/v1.0/2014.4.2/nova-chinac.tar.gz
#wget ftp://builder:dLoadAtOpenStack@125.208.28.24/build/Release/v1.0/2014.4.1/release_tag.txt
#wget http://125.208.28.24/centec/latest/neutron-centec-openvswitch-agent-1.2.3j-2.el7.centos.noarch.rpm
#wget http://125.208.28.24/centec/latest/scan_port.diff
echo "tar soft"
#tar xvf cinder-chinac.tar.gz
#tar xvf glance_store-chinac.tar.gz
#tar xvf neutron-chinac.tar.gz
tar xvf nova-chinac.tar.gz

echo "cp soft"
mv $pypwd/$novafile       $gengpwd/$date/$novafile-old
#mv $pypwd/$cinderfile     $gengpwd/$date/$cinderfile-old
#mv $pypwd/$neutronfile	  $gengpwd/$date/$neutronfile-old
#mv $pypwd/$glancefile	  $gengpwd/$date/$glancefile-old

#cp -rpf $gengpwd/$date/cinder-chinac/cinder  			$pypwd
#cp -rpf $gengpwd/$date/glance_store-chinac/glance_store 	$pypwd
cp -rpf $gengpwd/$date/nova-chinac/nova                         $pypwd
#cp -rpf $gengpwd/$date/neutron-chinac/neutron			$pypwd
#cp -rpf $gengpwd/$date/$neutronfile-old/plugins/centec		$pypwd/$centecfile
#yum install neutron-centec-openvswitch-agent-1.2.3j-2.el7.centos.noarch.rpm -y
#cd /usr/lib/python2.7/site-packages/neutron/plugins/centec/agent/ovs_agent 
#rm -rf scan_port.diff
#wget http://125.208.28.24/centec/latest/scan_port.diff
#patch < scan_port.diff
#cat $gengpwd/$date/release_tag.txt > /etc/openstack-release-tag
#echo "restart neutron-centec-openvswitch-agent.service"
#systemctl daemon-reload
#systemctl restart neutron-centec-openvswitch-agent.service
#service openstack-nova-compute restart
#echo "check version"
#rpm -qa |grep neutron-centec
#cat /etc/openstack-release-tag
service openstack-nova-compute restart
service openstack-nova-api restart
echo "2014.4.2" > /etc/openstack-release-tag
cat /etc/openstack-release-tag
