xenserver: Don't delete pidfile in stop_daemon.
[sliver-openvswitch.git] / xenserver / openvswitch-xen.spec
index 6c030a4..227c072 100644 (file)
@@ -228,8 +228,8 @@ done
 
 if [ "$1" = "1" ]; then    # $1 = 2 for upgrade
     # Configure system to use Open vSwitch
-    xe-switch-network-backend vswitch
-else
+    /opt/xensource/bin/xe-switch-network-backend vswitch
+else    # $1 = 2 for upgrade
 
     mode=$(cat /etc/xensource/network.conf)
     if [ "$mode" != "vswitch" ] && [ "$mode" != "openvswitch" ]; then
@@ -244,14 +244,27 @@ else
     printf "\n\n"
 fi
 
-%post %{module_package}
+%posttrans %{module_package}
 # Ensure that modprobe will find our modules.
+#
+# This has to be in %posttrans instead of %post because older versions
+# installed modules into a different directory and "rpm -U" runs the
+# new version's %post before removing the old version's files, so if
+# we use %post then depmod may find the old versions that are about to
+# be removed.
 depmod %{xen_version}
 
 %preun
-if [ "$1" = "0" ]; then     # $1 = 1 for upgrade
+if [ "$1" = "0" ]; then     # $1 = 0 for uninstall
+    # Configure system to use bridge
+    /opt/xensource/bin/xe-switch-network-backend bridge
+
+    # The "openvswitch" service should have been removed from
+    # "xe-switch-network-backend bridge".
     for s in openvswitch openvswitch-xapi-update; do
-        chkconfig --del $s || printf "Could not remove $s init script."
+        if chkconfig --list $s >/dev/null 2>&1; then
+            chkconfig --del $s || printf "Could not remove $s init script."
+        fi
     done
 fi
 
@@ -305,11 +318,10 @@ if [ "$1" = "0" ]; then     # $1 = 1 for upgrade
 
     # Remove saved XenServer scripts directory, but only if it's empty
     rmdir -p /usr/lib/openvswitch/xs-saved 2>/dev/null
-
-    # Configure system to use bridge
-    xe-switch-network-backend bridge
 fi
 
+exit 0
+
 %files
 %defattr(-,root,root)
 /etc/init.d/openvswitch