mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
packaging: Improve post-upgrade processing
$1 is "2" during package upgrade in %post section, this fixes the handling of $1 as per https://fedoraproject.org/wiki/Packaging:Scriptlets This improves handling of $1 during %post upgrade step. Some of the command/code are idempotent such as enabling and starting a service and can be run without any $1 checks. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
aa8a721c39
commit
449ff979bd
@ -434,10 +434,8 @@ if [ "$1" == "2" ] ; then
|
||||
fi
|
||||
|
||||
%post management
|
||||
if [ "$1" == "1" ] ; then
|
||||
/sbin/chkconfig --add cloudstack-management > /dev/null 2>&1 || true
|
||||
/sbin/chkconfig --level 345 cloudstack-management on > /dev/null 2>&1 || true
|
||||
fi
|
||||
/sbin/chkconfig --add cloudstack-management > /dev/null 2>&1 || true
|
||||
/sbin/chkconfig --level 345 cloudstack-management on > /dev/null 2>&1 || true
|
||||
|
||||
grep -s -q "db.cloud.driver=jdbc:mysql" "%{_sysconfdir}/%{name}/management/db.properties" || sed -i -e "\$adb.cloud.driver=jdbc:mysql" "%{_sysconfdir}/%{name}/management/db.properties"
|
||||
grep -s -q "db.usage.driver=jdbc:mysql" "%{_sysconfdir}/%{name}/management/db.properties" || sed -i -e "\$adb.usage.driver=jdbc:mysql" "%{_sysconfdir}/%{name}/management/db.properties"
|
||||
@ -522,18 +520,19 @@ if [ -d "%{_sysconfdir}/cloud" ] ; then
|
||||
fi
|
||||
|
||||
%post agent
|
||||
if [ "$1" == "1" ] ; then
|
||||
if [ "$1" == "2" ] ; then
|
||||
echo "Running %{_bindir}/%{name}-agent-upgrade to update bridge name for upgrade from CloudStack 4.0.x (and before) to CloudStack 4.1 (and later)"
|
||||
%{_bindir}/%{name}-agent-upgrade
|
||||
if [ ! -d %{_sysconfdir}/libvirt/hooks ] ; then
|
||||
mkdir %{_sysconfdir}/libvirt/hooks
|
||||
fi
|
||||
cp -a ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib/libvirtqemuhook %{_sysconfdir}/libvirt/hooks/qemu
|
||||
/sbin/service libvirtd restart
|
||||
/sbin/chkconfig --add cloudstack-agent > /dev/null 2>&1 || true
|
||||
/sbin/chkconfig --level 345 cloudstack-agent on > /dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
if [ ! -d %{_sysconfdir}/libvirt/hooks ] ; then
|
||||
mkdir %{_sysconfdir}/libvirt/hooks
|
||||
fi
|
||||
cp -a ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib/libvirtqemuhook %{_sysconfdir}/libvirt/hooks/qemu
|
||||
/sbin/service libvirtd restart
|
||||
/sbin/chkconfig --add cloudstack-agent > /dev/null 2>&1 || true
|
||||
/sbin/chkconfig --level 345 cloudstack-agent on > /dev/null 2>&1 || true
|
||||
|
||||
# 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
|
||||
|
||||
@ -392,9 +392,7 @@ if [ "$1" == "2" ] ; then
|
||||
fi
|
||||
|
||||
%post management
|
||||
if [ "$1" == "1" ] ; then
|
||||
/usr/bin/systemctl on cloudstack-management > /dev/null 2>&1 || true
|
||||
fi
|
||||
/usr/bin/systemctl on cloudstack-management > /dev/null 2>&1 || true
|
||||
|
||||
grep -s -q "db.cloud.driver=jdbc:mysql" "%{_sysconfdir}/%{name}/management/db.properties" || sed -i -e "\$adb.cloud.driver=jdbc:mysql" "%{_sysconfdir}/%{name}/management/db.properties"
|
||||
grep -s -q "db.usage.driver=jdbc:mysql" "%{_sysconfdir}/%{name}/management/db.properties" || sed -i -e "\$adb.usage.driver=jdbc:mysql" "%{_sysconfdir}/%{name}/management/db.properties"
|
||||
@ -424,16 +422,16 @@ if [ -d "%{_sysconfdir}/cloud" ] ; then
|
||||
fi
|
||||
|
||||
%post agent
|
||||
if [ "$1" == "1" ] ; then
|
||||
if [ "$1" == "2" ] ; then
|
||||
echo "Running %{_bindir}/%{name}-agent-upgrade to update bridge name for upgrade from CloudStack 4.0.x (and before) to CloudStack 4.1 (and later)"
|
||||
%{_bindir}/%{name}-agent-upgrade
|
||||
if [ ! -d %{_sysconfdir}/libvirt/hooks ] ; then
|
||||
mkdir %{_sysconfdir}/libvirt/hooks
|
||||
fi
|
||||
cp -a ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib/libvirtqemuhook %{_sysconfdir}/libvirt/hooks/qemu
|
||||
/sbin/service libvirtd restart
|
||||
/sbin/systemctl enable cloudstack-agent > /dev/null 2>&1 || true
|
||||
fi
|
||||
if [ ! -d %{_sysconfdir}/libvirt/hooks ] ; then
|
||||
mkdir %{_sysconfdir}/libvirt/hooks
|
||||
fi
|
||||
cp -a ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib/libvirtqemuhook %{_sysconfdir}/libvirt/hooks/qemu
|
||||
/sbin/service libvirtd restart
|
||||
/sbin/systemctl enable cloudstack-agent > /dev/null 2>&1 || true
|
||||
|
||||
# if saved configs from upgrade exist, copy them over
|
||||
if [ -f "%{_sysconfdir}/cloud.rpmsave/agent/agent.properties" ]; then
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user