- conf_file=/etc/openvswitch/conf.db
- schema_file=/usr/share/openvswitch/vswitch.ovsschema
- schema_ver=`ovsdb-tool schema-version "$schema_file"`
-
- load_module openvswitch_mod
-
- if test -n "$CORE_LIMIT"; then
- check_op "Setting core limit to $CORE_LIMIT" ulimit -c "$CORE_LIMIT"
- fi
-
- # Create an empty configuration database if it doesn't exist.
- if test ! -e $conf_file; then
- # Create configuration database.
- ovsdb-tool -vANY:console:emer create $conf_file $schema_file
- else
- # If schema version changed, then back up the old version.
- old_ver=`ovsdb-tool db-version "$conf_file"`
- if test "X$old_ver" != "X$schema_ver"; then
- cp "$conf_file" "$conf_file.backup$old_ver"
- fi
-
- # Upgrade or downgrade schema and compact database.
- ovsdb-tool -vANY:console:emer convert $conf_file $schema_file
- fi
-
- if test "$ENABLE_MONITOR" = y; then
- monitor_opt=--monitor
- else
- monitor_opt=
- fi
-
- if [ ! -d /var/run/openvswitch ]; then
- install -d -m 755 -o root -g root /var/run/openvswitch
- fi
-
- if [ ! -d /var/log/openvswitch ]; then
- install -d -m 755 -o root -g root /var/log/openvswitch
- fi
-
- if [ ! -d /var/log/openvswitch/cores ]; then
- install -d -m 755 -o root -g root /var/log/openvswitch/cores
- fi
-
- # Start ovsdb-server.
- set --
- set -- "$@" $conf_file
- set -- "$@" --verbose=ANY:console:emer --verbose=ANY:syslog:err
- set -- "$@" --log-file=/var/log/openvswitch/ovsdb-server.log
- set -- "$@" --detach --no-chdir --pidfile $monitor_opt
- set -- "$@" --remote punix:/var/run/openvswitch/db.sock
- set -- "$@" --remote db:Open_vSwitch,managers
- set -- "$@" --remote db:Open_vSwitch,manager_options
- set -- "$@" --private-key=db:SSL,private_key
- set -- "$@" --certificate=db:SSL,certificate
- set -- "$@" --bootstrap-ca-cert=db:SSL,ca_cert
- set -- "$@" $OVSDB_SERVER_OPTS
- echo -n "Starting ovsdb-server: "
- start-stop-daemon --start --quiet --oknodo \
- --pidfile /var/run/openvswitch/ovsdb-server.pid \
- --chdir /var/log/openvswitch/cores \
- --exec $ovsdb_server -- "$@"
- if running ovsdb-server; then
- echo "ovsdb-server."
- else
- echo " ERROR."
- fi
-
- ovs-vsctl --no-wait --timeout=5 init -- set Open_vSwitch . db-version="$schema_ver"
-
- set_system_info
-
- # Start ovs-vswitchd.
- set --
- set -- "$@" --verbose=ANY:console:emer --verbose=ANY:syslog:err
- set -- "$@" --log-file=/var/log/openvswitch/ovs-vswitchd.log
- set -- "$@" --detach --no-chdir --pidfile $monitor_opt
- set -- "$@" unix:/var/run/openvswitch/db.sock
- set -- "$@" $OVS_VSWITCHD_OPTS
- echo -n "Starting ovs-vswitchd: "
- start-stop-daemon --start --quiet --oknodo \
- --pidfile /var/run/openvswitch/ovs-vswitchd.pid \
- --chdir /var/log/openvswitch/cores \
- --exec $ovs_vswitchd -- "$@"
- if running ovs-vswitchd; then
- echo "ovs-vswitchd."
- else
- echo " ERROR."
- fi
- ;;
- stop)
- echo -n "Stopping ovs-vswitchd: "
- start-stop-daemon --stop --quiet --oknodo --retry 5 \
- --pidfile /var/run/openvswitch/ovs-vswitchd.pid \
- --chdir /var/log/openvswitch/cores \
- --exec $ovs_vswitchd
- echo "ovs-vswitchd."
-
- echo -n "Stopping ovsdb-server: "
- start-stop-daemon --stop --quiet --oknodo --retry 5 \
- --pidfile /var/run/openvswitch/ovsdb-server.pid \
- --chdir /var/log/openvswitch/cores \
- --exec $ovsdb_server
- echo "ovsdb-server."
- ;;
- force-stop)
- echo -n "Forcefully stopping ovs-vswitchd: "
- force_stop ovs-vswitchd
- if ! running ovs-vswitchd; then
- echo "ovs-vswitchd."
- else
- echo " ERROR."
- fi
-
- echo -n "Forcefully stopping ovsdb-server: "
- force_stop ovsdb-server
- if ! running ovsdb-server; then
- echo "ovsdb-server."
- else
- echo " ERROR."
- fi