- 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 /etc/openvswitch/conf.db; then
- install -d -m 755 -o root -g root /etc/openvswitch
-
- # Create configuration database.
- ovsdb-tool -vANY:console:emer \
- create /etc/openvswitch/conf.db \
- /usr/share/openvswitch/vswitch.ovsschema
- else
- # Upgrade or downgrade schema and compact database.
- ovsdb-tool -vANY:console:emer \
- convert /etc/openvswitch/conf.db \
- /usr/share/openvswitch/vswitch.ovsschema
- 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
-
- # Start ovsdb-server.
- set --
- set -- "$@" /etc/openvswitch/conf.db
- set -- "$@" --verbose=ANY:console:emer --verbose=ANY:syslog:err
- set -- "$@" --log-file=/var/log/openvswitch/ovsdb-server.log
- set -- "$@" --detach --pidfile $monitor_opt
- set -- "$@" --remote punix:/var/run/openvswitch/db.sock
- set -- "$@" --remote db:Open_vSwitch,managers
- 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 \
- --pidfile /var/run/openvswitch/ovsdb-server.pid \
- --exec $ovsdb_server -- "$@"
- if running ovsdb-server; then
- echo "ovsdb-server."
- else
- echo " ERROR."
- fi
-
- ovs-vsctl --no-wait init
-
- # Start ovs-vswitchd.
- set --
- set -- "$@" --verbose=ANY:console:emer --verbose=ANY:syslog:err
- set -- "$@" --log-file=/var/log/openvswitch/ovs-vswitchd.log
- set -- "$@" --detach --pidfile $monitor_opt
- set -- "$@" unix:/var/run/openvswitch/db.sock
- set -- "$@" $OVS_VSWITCHD_OPTS
- echo -n "Starting ovs-vswitchd: "
- start-stop-daemon --start --quiet \
- --pidfile /var/run/openvswitch/ovs-vswitchd.pid \
- --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 \
- --pidfile /var/run/openvswitch/ovs-vswitchd.pid \
- --exec $ovs_vswitchd
- echo "ovs-vswitchd."
-
- echo -n "Stopping ovsdb-server: "
- start-stop-daemon --stop --quiet --oknodo \
- --pidfile /var/run/openvswitch/ovsdb-server.pid \
- --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