summaryrefslogtreecommitdiff
path: root/rhel/etc_init.d_openvswitch
blob: 7a4cfbab5f732a5b5a414e6da13b6be3e79b3c38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/sh
#
# openvswitch
#
# chkconfig: 2345 09 91
# description: Manage Open vSwitch kernel modules and user-space daemons

# Copyright (C) 2009, 2010, 2011, 2013 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
# Required-Start:
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Open vSwitch switch
### END INIT INFO

SYSTEMCTL_SKIP_REDIRECT=yes
SYSTEMD_NO_WRAP=yes

. /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
    "$@"

    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
        exit $?
        ;;
    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