Skip to content

Commit a588efc

Browse files
author
Marcus Sorensen
committed
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 <marcus@betterservers.com> 1364409632 -0600
1 parent f414b8a commit a588efc

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

packaging/centos63/cloud.spec

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ Requires: jakarta-commons-daemon-jsvc
120120
Requires: perl
121121
Provides: cloud-agent
122122
Obsoletes: cloud-agent < 4.1.0
123+
Obsoletes: cloud-agent-libs < 4.1.0
123124
Obsoletes: cloud-test < 4.1.0
124125
Group: System Environment/Libraries
125126
%description agent
@@ -333,6 +334,12 @@ echo "cloud soft nofile 4096" >> /etc/security/limits.conf
333334
rm -rf %{_localstatedir}/cache/cloud
334335
# user harcoded here, also hardcoded on wscript
335336

337+
# save old configs if they exist (for upgrade). Otherwise we may lose them
338+
# when the old packages are erased. There are a lot of properties files here.
339+
if [ -d "%{_sysconfdir}/cloud" ] ; then
340+
mv %{_sysconfdir}/cloud %{_sysconfdir}/cloud.rpmsave
341+
fi
342+
336343
%post management
337344
if [ "$1" == "1" ] ; then
338345
/sbin/chkconfig --add cloudstack-management > /dev/null 2>&1 || true
@@ -354,6 +361,52 @@ if getent passwd cloud | grep -q /var/lib/cloud; then
354361
sed -i 's/\/var\/lib\/cloud\/management/\/var\/cloudstack\/management/g' /etc/passwd
355362
fi
356363

364+
# if saved configs from upgrade exist, copy them over
365+
if [ -d "%{_sysconfdir}/cloud.rpmsave/management" ]; then
366+
cp -p %{_sysconfdir}/cloud.rpmsave/management/db.properties %{_sysconfdir}/%{name}/management
367+
cp -p %{_sysconfdir}/cloud.rpmsave/management/key %{_sysconfdir}/%{name}/management
368+
fi
369+
370+
# Choose server.xml and tomcat.conf links based on old config, if exists
371+
serverxml=%{_sysconfdir}/%{name}/management/server.xml
372+
oldserverxml=%{_sysconfdir}/cloud.rpmsave/management/server.xml
373+
if [ -L $oldserverxml ] ; then
374+
if stat -c %N $oldserverxml | grep -q server-nonssl ; then
375+
if [ -L $serverxml ]; then rm -f $serverxml; fi
376+
ln -s %{_sysconfdir}/%{name}/management/server-nonssl.xml $serverxml
377+
elif stat -c %N $oldserverxml| grep -q server-ssl ; then
378+
if [ -L $serverxml ]; then rm -f $serverxml; fi
379+
ln -s %{_sysconfdir}/%{name}/management/server-ssl.xml $serverxml
380+
fi
381+
fi
382+
383+
tomcatconf=%{_sysconfdir}/%{name}/management/tomcat6.conf
384+
oldtomcatconf=%{_sysconfdir}/cloud.rpmsave/management/tomcat6.conf
385+
if [ -L $oldtomcatconf ] ; then
386+
if stat -c %N $oldtomcatconf | grep -q tomcat6-nonssl ; then
387+
if [ -L $tomcatconf ]; then rm -f $tomcatconf; fi
388+
ln -s %{_sysconfdir}/%{name}/management/tomcat6-nonssl.conf $tomcatconf
389+
elif stat -c %N $oldtomcatconf| grep -q tomcat6-ssl ; then
390+
if [ -L $tomcatconf ]; then rm -f $tomcatconf; fi
391+
ln -s %{_sysconfdir}/%{name}/management/tomcat6-ssl.conf $tomcatconf
392+
fi
393+
fi
394+
395+
%pre agent
396+
397+
# save old configs if they exist (for upgrade). Otherwise we may lose them
398+
# when the old packages are erased. There are a lot of properties files here.
399+
if [ -d "%{_sysconfdir}/cloud" ] ; then
400+
mv %{_sysconfdir}/cloud %{_sysconfdir}/cloudr.rpmsave
401+
fi
402+
403+
%post agent
404+
405+
# if saved configs from upgrade exist, copy them over
406+
if [ -f "%{_sysconfdir}/cloud.rpmsave/agent/agent.properties" ]; then
407+
mv %{_sysconfdir}/%{name}/agent/agent.properties %{_sysconfdir}/%{name}/agent/agent.properties.rpmnew
408+
cp -p %{_sysconfdir}/cloud.rpmsave/agent/agent.properties %{_sysconfdir}/%{name}/agent
409+
fi
357410

358411
#%post awsapi
359412
#if [ -d "%{_datadir}/%{name}-management" ] ; then

0 commit comments

Comments
 (0)