#!/bin/sh # # start/stop openvswitch # # chkconfig: 2345 9 99 # description: Activates/Deactivates all Open vSwitch to start at boot time. # processname: openvswitchd # config: /usr/local/etc/openvswitch/conf.db # pidfile: /usr/local/var/run/openvswitch/ovs-vswitchd.pid # PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin export PATH # Source function library. . /etc/rc.d/init.d/functions stop() { echo -n "Stopping openvswitch: " if [ -e /usr/local/var/run/openvswitch/ovs-vswitchd.pid ]; then pid=$(cat /usr/local/var/run/openvswitch/ovs-vswitchd.pid) /usr/local/bin/ovs-appctl -t /usr/local/var/run/openvswitch/ovs-vswitchd.$pid.ctl exit /bin/kill -9 $pid rm -f /usr/local/var/run/openvswitch/ovs-vswitchd.$pid.ctl fi if [ -e /usr/local/var/run/openvswitch/ovsdb-server.pid ]; then pid=$(cat /usr/local/var/run/openvswitch/ovsdb-server.pid) /usr/local/bin/ovs-appctl -t /usr/local/var/run/openvswitch/ovsdb-server.$pid.ctl exit rm -f /usr/local/var/run/openvswitch/ovsdb-server.$pid.ctl fi rm -f /var/lock/subsys/openvswitchd } start() { echo -n "Starting openvswitch: " if [ `lsmod | grep -c "openvswitch_mod"` -eq 0 ]; then /sbin/modprobe openvswitch_mod fi if [ `lsmod | grep -c "8021q"` -eq 0 ]; then /sbin/modprobe 8021q fi /usr/local/sbin/ovsdb-server /usr/local/etc/openvswitch/conf.db --remote=punix:/usr/local/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,manager_options --private-key=db:SSL,private_key --certificate=db:SSL,certificate --bootstrap-ca-cert=db:SSL,ca_cert --pidfile --detach /usr/local/bin/ovs-vsctl --no-wait init /usr/local/sbin/ovs-vswitchd unix:/usr/local/var/run/openvswitch/db.sock --pidfile --detach touch /var/lock/subsys/openvswitchd } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status ovs-vswitchd ;; restart) stop start ;; *) echo "Usage: openvswitchd {start|stop|status|restart}" exit 1 esac exit 0