Blob Blame History Raw
#!/bin/sh
#
# openvswitch
#
# chkconfig: 2345 09 91
# description: Manage Open vSwitch kernel modules and user-space daemons

# Copyright (C) 2009, 2010, 2011 Nicira, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
### BEGIN INIT INFO
# Provides:          openvswitch-switch
# Required-Start:
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Open vSwitch switch
### END INIT INFO

. /usr/share/openvswitch/scripts/ovs-lib || exit 1
test -e /etc/sysconfig/openvswitch && . /etc/sysconfig/openvswitch

start () {
    set ovs_ctl ${1-start}
    set "$@" --system-id=random
    if test X"$FORCE_COREFILES" != X; then
	set "$@" --force-corefiles="$FORCE_COREFILES"
    fi
    if test X"$OVSDB_SERVER_PRIORITY" != X; then
	set "$@" --ovsdb-server-priority="$OVSDB_SERVER_PRIORITY"
    fi
    if test X"$VSWITCHD_PRIORITY" != X; then
	set "$@" --ovs-vswitchd-priority="$VSWITCHD_PRIORITY"
    fi
    if test X"$VSWITCHD_MLOCKALL" != X; then
	set "$@" --mlockall="$VSWITCHD_MLOCKALL"
    fi
    set "$@" $OVS_CTL_OPTS
    "$@"

# RHEL6 does not support OVS GRE tunneling yet, do not add iptables GRE rule
#    ovs_ctl --protocol=gre enable-protocol

    touch /var/lock/subsys/openvswitch
}

stop () {
    ovs_ctl stop
    rm -f /var/lock/subsys/openvswitch
}

restart () {
    if [ "$1" = "--save-flows=yes" ]; then
        start restart
    else
        stop
        start
    fi
}

case $1 in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        shift
        restart "$@"
        ;;
    reload|force-reload)
        # Nothing to do.
        ;;
    status)
        ovs_ctl status
        ;;
    version)
        ovs_ctl version
        ;;
    force-reload-kmod)
        start force-reload-kmod
        ;;
    help)
        printf "$0 [start|stop|restart|reload|force-reload|status|version|force-reload-kmod]\n"
        ;;
    *)
        printf "Unknown command: $1\n"
        exit 1
        ;;
esac