-: ${ENABLE_MONITOR:=y}
-: ${FORCE_COREFILES:=y}
-
-# Config variables specific to ovsdb-server
-: ${OVSDB_SERVER_REMOTES:=punix:/var/run/openvswitch/db.sock db:Open_vSwitch,manager_options}
-: ${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:=}
-
-: ${OVS_XAPI_SYNC_PIDFILE:=/var/run/openvswitch/ovs-xapi-sync.pid}
-
-# Full paths to executables & modules
-ovsdb_server="/usr/sbin/ovsdb-server"
-ovsdb_tool="/usr/bin/ovsdb-tool"
-vswitchd="/usr/sbin/ovs-vswitchd"
-dpctl="/usr/bin/ovs-dpctl"
-appctl="/usr/bin/ovs-appctl"
-ofctl="/usr/bin/ovs-ofctl"
-vsctl="/usr/bin/ovs-vsctl"
-
-if test "$ENABLE_MONITOR" = "y"; then
- monitor_opt="--monitor"
-else
- monitor_opt=
-fi
-
-function hup_monitor_external_ids {
- if [ -e /var/run/openvswitch/ovs-xapi-sync.pid ]; then
- action "Configuring Open vSwitch external IDs" kill -HUP `cat /var/run/openvswitch/ovs-xapi-sync.pid`
- fi
-}
-
-function turn_on_corefiles {
- ulimit -Sc 67108864
-}
-
-function remove_all_dp {
- for dp in $($dpctl dump-dps); do
- action "Removing datapath: $dp" "$dpctl" del-dp "$dp"
- done
-}
-
-function insert_modules_if_required {
- if test -e /sys/module/bridge; then
- bridges=`echo /sys/class/net/*/bridge | sed 's,/sys/class/net/,,g;s,/bridge,,g'`
- if test "$bridges" != "*"; then
- log_warning_msg "not removing bridge module because bridges exist ($bridges)"
- else
- action "removing bridge module" rmmod bridge
- fi
- fi
- if ! lsmod | grep -q "openvswitch_mod"; then
- action "Inserting llc module" modprobe llc
- action "Inserting openvswitch module" modprobe openvswitch_mod
- fi
-}
-
-function remove_modules {
- 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
-
- # cd to daemon's run_dir so core files get dumped into a sensible place.
- eval local run_dir=\$${DAEMON}_RUN_DIR
- if [ ! -d "$run_dir" ]; then
- install -d -m 755 -o root -g root "$run_dir"
- fi
- cd "$run_dir"
-
- # Configure log levels.
- eval local syslog_loglevel=\$${DAEMON}_SYSLOG_LOGLEVEL
- eval local file_loglevel=\$${DAEMON}_FILE_LOGLEVEL
- eval local logfile=\$${DAEMON}_LOGFILE
- set -- "$@" -vANY:CONSOLE:EMER -vANY:SYSLOG:"$syslog_loglevel"
- if test -n "$file_loglevel" && test -n "$logfile"; then
- install -d -m 755 -o root -g root `dirname "$logfile"`
- set -- "$@" --log-file="$logfile" -vANY:FILE:"$file_loglevel"
- fi
-
- # Configure leak checker.
- eval local memleak_logfile=\$${DAEMON}_MEMLEAK_LOGFILE
- if test -n "$memleak_logfile"; then
- set -- "$@" --check-leaks="$memleak_logfile"
- if test -e "$memleak_logfile"; then
- mv "$memleak_logfile" "$memleak_logfile.prev"
- fi
- fi
-
- # Configure debugging wrappers.
- eval local strace_log=\$${DAEMON}_STRACE_LOG
- eval local strace_opt=\$${DAEMON}_STRACE_OPT
- eval local valgrind_log=\$${DAEMON}_VALGRIND_LOG
- eval local valgrind_opt=\$${DAEMON}_VALGRIND_OPT
- if test -n "$strace_log" && test -n "$valgrind_log"; then
- printf "Can not start with both VALGRIND and STRACE\n"
- exit 1
- elif test -n "$strace_log"; then
- local mode=strace
- set -- strace -o "$strace_log" $strace_opt "$@"
- elif test -n "$valgrind_log"; then
- local mode=valgrind
- set -- valgrind --log-file="$valgrind_log" $valgrind_opt "$@"
- else
- local mode=production
- eval local pidfile=\$${DAEMON}_PIDFILE
- install -d -m 755 -o root -g root `dirname $pidfile`
- set -- "$@" --pidfile="$pidfile" --detach $monitor_opt --no-chdir
- fi
-
- # Configure niceness.
- eval local priority=\$${DAEMON}_PRIORITY
- if test -n "$priority"; then
- set -- nice -n $priority "$@"