-NETWORK_MODE=$(cat /etc/xensource/network.conf)
-if test "$NETWORK_MODE" = bridge; then
- echo "Open vSwitch disabled (/etc/xensource/network.conf is 'bridge')" >&2
- exit 0
-fi
-
-# General config variables in /etc/sysconfig/openvswitch
-if test "$PRODUCT_VERSION" = "5.5.0"; then
- # XenServer 5.5.0 needs ovs-brcompatd and /proc/net simulation.
- : ${ENABLE_BRCOMPAT:=y}
- : ${ENABLE_FAKE_PROC_NET:=y}
- : ${ENABLE_XENSERVERD:=y}
-else
- # Later versions don't need them.
- : ${ENABLE_BRCOMPAT:=n}
- : ${ENABLE_FAKE_PROC_NET:=n}
- : ${ENABLE_XENSERVERD:=n}
-fi
-: ${ENABLE_MONITOR:=y}
-: ${FORCE_COREFILES:=y}
-
-# Config variables specific to ovsdb-server
-: ${OVSDB_SERVER_REMOTES:=punix:/var/run/openvswitch/db.sock db:Open_vSwitch,managers}
-: ${OVSDB_SERVER_DB:=/etc/openvswitch/conf.db}
-: ${OVSDB_SERVER_PIDFILE:=/var/run/openvswitch/ovsdb-server.pid}
-: ${OVSDB_SERVER_RUN_DIR:=/var/xen/openvswitch}
-: ${OVSDB_SERVER_PRIORITY:=-10}
-: ${OVSDB_SERVER_LOGFILE:=/var/log/openvswitch/ovsdb-server.log}
-: ${OVSDB_SERVER_FILE_LOGLEVEL:=INFO}
-: ${OVSDB_SERVER_SYSLOG_LOGLEVEL:=ERR}
-: ${OVSDB_SERVER_MEMLEAK_LOGFILE:=}
-: ${OVSDB_SERVER_STRACE_LOG:=}
-: ${OVSDB_SERVER_STRACE_OPT:=}
-: ${OVSDB_SERVER_VALGRIND_LOG:=}
-: ${OVSDB_SERVER_VALGRIND_OPT:=}
-
-# Config variables specific to ovs-vswitchd
-: ${VSWITCHD_OVSDB_SERVER:=unix:/var/run/openvswitch/db.sock}
-: ${VSWITCHD_OVSDB_SCHEMA:=/usr/share/openvswitch/vswitch.ovsschema}
-: ${VSWITCHD_PIDFILE:=/var/run/openvswitch/ovs-vswitchd.pid}
-: ${VSWITCHD_RUN_DIR:=/var/xen/openvswitch}
-: ${VSWITCHD_PRIORITY:=-10}
-: ${VSWITCHD_MLOCKALL:=yes}
-: ${VSWITCHD_LOGFILE:=/var/log/openvswitch/ovs-vswitchd.log}
-: ${VSWITCHD_FILE_LOGLEVEL:=INFO}
-: ${VSWITCHD_SYSLOG_LOGLEVEL:=ERR}
-: ${VSWITCHD_MEMLEAK_LOGFILE:=}
-: ${VSWITCHD_STRACE_LOG:=}
-: ${VSWITCHD_STRACE_OPT:=}
-: ${VSWITCHD_VALGRIND_LOG:=}
-: ${VSWITCHD_VALGRIND_OPT:=}
-
-# Config variables specific to ovs-brcompatd
-: ${BRCOMPATD_PIDFILE:=/var/run/openvswitch/ovs-brcompatd.pid}
-: ${BRCOMPATD_RUN_DIR:=/var/xen/openvswitch}
-: ${BRCOMPATD_PRIORITY:=-10}
-: ${BRCOMPATD_LOGFILE:=/var/log/openvswitch/ovs-brcompatd.log}
-: ${BRCOMPATD_FILE_LOGLEVEL:=INFO}
-: ${BRCOMPATD_SYSLOG_LOGLEVEL:=ERR}
-: ${BRCOMPATD_MEMLEAK_LOGFILE:=}
-: ${BRCOMPATD_STRACE_LOG:=}
-: ${BRCOMPATD_STRACE_OPT:=}
-: ${BRCOMPATD_VALGRIND_LOG:=}
-: ${BRCOMPATD_VALGRIND_OPT:=}
-
-# Config variables specific to ovs-xenserverd
-: ${XENSERVERD_PIDFILE:=/var/run/openvswitch/ovs-xenserverd.pid}
-: ${XENSERVERD_RUN_DIR:=/var/xen/openvswitch}
-: ${XENSERVERD_PRIORITY:=}
-: ${XENSERVERD_LOGFILE:=}
-: ${XENSERVERD_FILE_LOGLEVEL:=}
-: ${XENSERVERD_SYSLOG_LOGLEVEL:=}
-: ${XENSERVERD_MEMLEAK_LOGFILE:=}
-: ${XENSERVERD_STRACE_LOG:=}
-: ${XENSERVERD_STRACE_OPT:=}
-: ${XENSERVERD_VALGRIND_LOG:=}
-: ${XENSERVERD_VALGRIND_OPT:=}
-
-# Full paths to executables & modules
-ovsdb_server="/usr/sbin/ovsdb-server"
-ovsdb_tool="/usr/bin/ovsdb-tool"
-vswitchd="/usr/sbin/ovs-vswitchd"
-brcompatd="/usr/sbin/ovs-brcompatd"
-xenserverd="/usr/sbin/ovs-xenserverd"
-dpctl="/usr/bin/ovs-dpctl"
-appctl="/usr/bin/ovs-appctl"
-ofctl="/usr/bin/ovs-ofctl"
-vsctl="/usr/bin/ovs-vsctl"
-
-if [ "$ENABLE_FAKE_PROC_NET" = "y" ]; then
- if [ "$ENABLE_BRCOMPAT" != "y" ]; then
- warning "FAKE_PROC_NET required BRCOMPAT which was disabled. Force enabling."
- ENABLE_BRCOMPAT="y"
- fi
-fi
-
-if test "$ENABLE_MONITOR" = "y"; then
- monitor_opt="--monitor"
-else
- monitor_opt=
-fi
-
-function dp_list {
- "$dpctl" show | grep '^dp[0-9]\+:' | cut -d':' -f 1
-}
-
-function turn_on_corefiles {
- ulimit -Sc 67108864
-}
-
-function remove_all_dp {
- for dp in $(dp_list); do
- action "Removing datapath: $dp" "$dpctl" del-dp "$dp"
- done
-}
-
-function insert_modules_if_required {
- if ! lsmod | grep -q "openvswitch_mod"; then
- action "Inserting llc module" modprobe llc
- action "Inserting openvswitch module" modprobe openvswitch_mod
- fi
- if [ "$ENABLE_BRCOMPAT" = "y" ] && [ -n "$BRCOMPATD_PIDFILE" ] && ! lsmod | grep -q "brcompat_mod"; then
- action "Inserting brcompat module" modprobe brcompat_mod
- fi
-}
-
-function remove_modules {
- if lsmod | grep -q "brcompat_mod"; then
- action "Removing brcompat module" rmmod brcompat_mod.ko
- fi
- if lsmod | grep -q "openvswitch_mod"; then
- action "Removing openvswitch module" rmmod openvswitch_mod.ko
- fi
-}
-
-function start_daemon {
- local DAEMON=$1
- shift
- local BINARY=$1