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 <mar...@betterservers.com> 1364409632 -0600 Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/a588efc0 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a588efc0 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a588efc0 Branch: refs/heads/affinity_groups Commit: a588efc0cc83c067dbe78bf538be32253072290a Parents: f414b8a Author: Marcus Sorensen <mar...@betterservers.com> Authored: Wed Mar 27 12:40:32 2013 -0600 Committer: Marcus Sorensen <mar...@betterservers.com> Committed: Wed Mar 27 12:40:32 2013 -0600 ---------------------------------------------------------------------- packaging/centos63/cloud.spec | 53 ++++++++++++++++++++++++++++++++++++ 1 files changed, 53 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a588efc0/packaging/centos63/cloud.spec ---------------------------------------------------------------------- diff --git a/packaging/centos63/cloud.spec b/packaging/centos63/cloud.spec index 893691c..3fd0dd4 100644 --- a/packaging/centos63/cloud.spec +++ b/packaging/centos63/cloud.spec @@ -120,6 +120,7 @@ Requires: jakarta-commons-daemon-jsvc Requires: perl 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 @@ -333,6 +334,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 @@ -354,6 +361,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