Updated Branches:
  refs/heads/4.1 0828b0b23 -> 0f8320095

Summary: RPM - recover configs during upgrade

Detail: Uninstallation of old RPMs wipes out some of the configs, and makes it
difficult to reapply existing configs. This change moves the config directory
to cloud.rpmsave, and then pulls in necessary files from that location during
post install of agent and management server.

Test passed:
install 4.0 RPMs, set up advanced zone
build 4.1 RPMs via package.sh, with this patch
install 4.1 RPMs
restart cloudstack-management, cloudstack-agent
verify management, agent, and zone is operational

BUG-ID: CLOUDSTACK-1694
Signed-off-by: Marcus Sorensen <[email protected]> 1364409632 -0600


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/0f832009
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/0f832009
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/0f832009

Branch: refs/heads/4.1
Commit: 0f8320095c70862debdf8f173219c359451b2f2a
Parents: 0828b0b
Author: Marcus Sorensen <[email protected]>
Authored: Wed Mar 27 12:40:32 2013 -0600
Committer: Chip Childers <[email protected]>
Committed: Wed Mar 27 18:47:48 2013 +0000

----------------------------------------------------------------------
 packaging/centos63/cloud.spec |   53 ++++++++++++++++++++++++++++++++++++
 1 files changed, 53 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0f832009/packaging/centos63/cloud.spec
----------------------------------------------------------------------
diff --git a/packaging/centos63/cloud.spec b/packaging/centos63/cloud.spec
index 595261c..f7cac4a 100644
--- a/packaging/centos63/cloud.spec
+++ b/packaging/centos63/cloud.spec
@@ -119,6 +119,7 @@ Requires: jakarta-commons-daemon
 Requires: jakarta-commons-daemon-jsvc
 Provides: cloud-agent
 Obsoletes: cloud-agent < 4.1.0
+Obsoletes: cloud-agent-libs < 4.1.0
 Obsoletes: cloud-test < 4.1.0
 Group: System Environment/Libraries
 %description agent
@@ -336,6 +337,12 @@ echo "cloud soft nofile 4096" >> /etc/security/limits.conf
 rm -rf %{_localstatedir}/cache/cloud
 # user harcoded here, also hardcoded on wscript
 
+# save old configs if they exist (for upgrade). Otherwise we may lose them
+# when the old packages are erased. There are a lot of properties files here.
+if [ -d "%{_sysconfdir}/cloud" ] ; then
+    mv %{_sysconfdir}/cloud %{_sysconfdir}/cloud.rpmsave
+fi
+
 %post management
 if [ "$1" == "1" ] ; then
     /sbin/chkconfig --add cloudstack-management > /dev/null 2>&1 || true
@@ -357,6 +364,52 @@ if getent passwd cloud | grep -q /var/lib/cloud; then
     sed -i 's/\/var\/lib\/cloud\/management/\/var\/cloudstack\/management/g' 
/etc/passwd
 fi
 
+# if saved configs from upgrade exist, copy them over
+if [ -d "%{_sysconfdir}/cloud.rpmsave/management" ]; then
+    cp -p %{_sysconfdir}/cloud.rpmsave/management/db.properties 
%{_sysconfdir}/%{name}/management
+    cp -p %{_sysconfdir}/cloud.rpmsave/management/key 
%{_sysconfdir}/%{name}/management
+fi
+
+# Choose server.xml and tomcat.conf links based on old config, if exists
+serverxml=%{_sysconfdir}/%{name}/management/server.xml
+oldserverxml=%{_sysconfdir}/cloud.rpmsave/management/server.xml
+if [ -L $oldserverxml ] ; then
+    if stat -c %N $oldserverxml | grep -q server-nonssl ; then
+        if [ -L $serverxml ]; then rm -f $serverxml; fi
+        ln -s %{_sysconfdir}/%{name}/management/server-nonssl.xml $serverxml
+    elif stat -c %N $oldserverxml| grep -q server-ssl ; then
+        if [ -L $serverxml ]; then rm -f $serverxml; fi
+        ln -s %{_sysconfdir}/%{name}/management/server-ssl.xml $serverxml
+    fi
+fi
+
+tomcatconf=%{_sysconfdir}/%{name}/management/tomcat6.conf
+oldtomcatconf=%{_sysconfdir}/cloud.rpmsave/management/tomcat6.conf
+if [ -L $oldtomcatconf ] ; then
+    if stat -c %N $oldtomcatconf | grep -q tomcat6-nonssl ; then
+        if [ -L $tomcatconf ]; then rm -f $tomcatconf; fi
+        ln -s %{_sysconfdir}/%{name}/management/tomcat6-nonssl.conf $tomcatconf
+    elif stat -c %N $oldtomcatconf| grep -q tomcat6-ssl ; then
+        if [ -L $tomcatconf ]; then rm -f $tomcatconf; fi
+        ln -s %{_sysconfdir}/%{name}/management/tomcat6-ssl.conf $tomcatconf
+    fi
+fi
+
+%pre agent
+
+# save old configs if they exist (for upgrade). Otherwise we may lose them
+# when the old packages are erased. There are a lot of properties files here.
+if [ -d "%{_sysconfdir}/cloud" ] ; then
+    mv %{_sysconfdir}/cloud %{_sysconfdir}/cloudr.rpmsave
+fi
+
+%post agent
+
+# if saved configs from upgrade exist, copy them over
+if [ -f "%{_sysconfdir}/cloud.rpmsave/agent/agent.properties" ]; then
+    mv %{_sysconfdir}/%{name}/agent/agent.properties  
%{_sysconfdir}/%{name}/agent/agent.properties.rpmnew
+    cp -p %{_sysconfdir}/cloud.rpmsave/agent/agent.properties 
%{_sysconfdir}/%{name}/agent
+fi
 
 #%post awsapi
 #if [ -d "%{_datadir}/%{name}-management" ] ; then

Reply via email to