ofp-actions: Assert variable actions have len>0.
[cascardo/ovs.git] / debian / openvswitch-switch.init
index 84aa450..a045f3b 100755 (executable)
 
 (test -x /usr/sbin/ovs-vswitchd && test -x /usr/sbin/ovsdb-server) || exit 0
 
+_SYSTEMCTL_SKIP_REDIRECT=yes
+
 . /usr/share/openvswitch/scripts/ovs-lib
 test -e /etc/default/openvswitch-switch && . /etc/default/openvswitch-switch
 
 network_interfaces () {
     INTERFACES="/etc/network/interfaces"
     [ -e "${INTERFACES}" ] || return
-    bridges=`awk '{ if ($1 == "allow-ovs") { print $2; } }' "${INTERFACES}"`
+    bridges=`ifquery --allow ovs --list`
     [ -n "${bridges}" ] && $1 --allow=ovs ${bridges}
 }
 
@@ -66,11 +68,13 @@ start () {
     fi
     set "$@" $OVS_CTL_OPTS
     "$@" || exit $?
-    [ "$2" = "start" ] && network_interfaces ifup
+    if [ "$2" = "start" ] && [ "$READ_INTERFACES" != "no" ]; then
+        network_interfaces ifup
+    fi
 }
 
 stop () {
-    network_interfaces ifdown
+    [ "$READ_INTERFACES" != "no" ] && network_interfaces ifdown
     ovs_ctl stop
 }
 
@@ -83,11 +87,15 @@ restart () {
         depmod -a
 
         if [ -e /sys/module/openvswitch ]; then
-            LOADED_SRCVERSION=`cat /sys/module/openvswitch/srcversion`
-            LOADED_VERSION=`cat /sys/module/openvswitch/version`
+            LOADED_SRCVERSION=`cat /sys/module/openvswitch/srcversion \
+                               2>/dev/null`
+            LOADED_VERSION=`cat /sys/module/openvswitch/version \
+                            2>/dev/null`
         elif [ -e /sys/module/openvswitch_mod ]; then
-            LOADED_SRCVERSION=`cat /sys/module/openvswitch_mod/srcversion`
-            LOADED_VERSION=`cat /sys/module/openvswitch_mod/version`
+            LOADED_SRCVERSION=`cat /sys/module/openvswitch_mod/srcversion \
+                               2>/dev/null`
+            LOADED_VERSION=`cat /sys/module/openvswitch_mod/version \
+                            2>/dev/null`
         fi
         SRCVERSION=`modinfo -F srcversion openvswitch 2>/dev/null`
         VERSION=`modinfo -F version openvswitch 2>/dev/null`
@@ -105,8 +113,8 @@ restart () {
             start restart
         fi
     else
-        stop
-        start
+        READ_INTERFACES="no" stop
+        READ_INTERFACES="no" start
     fi
 }