]>
Commit | Line | Data |
---|---|---|
43bb5f82 | 1 | #!/bin/sh |
064af421 | 2 | # |
bc391960 | 3 | # openvswitch |
064af421 BP |
4 | # |
5 | # chkconfig: 2345 09 91 | |
bc391960 | 6 | # description: Manage Open vSwitch kernel modules and user-space daemons |
064af421 | 7 | |
e0edde6f | 8 | # Copyright (C) 2009, 2010, 2011 Nicira, Inc. |
064af421 | 9 | # |
a14bc59f BP |
10 | # Licensed under the Apache License, Version 2.0 (the "License"); |
11 | # you may not use this file except in compliance with the License. | |
12 | # You may obtain a copy of the License at: | |
064af421 | 13 | # |
a14bc59f | 14 | # http://www.apache.org/licenses/LICENSE-2.0 |
064af421 | 15 | # |
a14bc59f BP |
16 | # Unless required by applicable law or agreed to in writing, software |
17 | # distributed under the License is distributed on an "AS IS" BASIS, | |
18 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
19 | # See the License for the specific language governing permissions and | |
20 | # limitations under the License. | |
72dfb3b4 BP |
21 | ### BEGIN INIT INFO |
22 | # Provides: openvswitch-switch | |
7f9bd4e8 JP |
23 | # Required-Start: |
24 | # Required-Stop: | |
72dfb3b4 BP |
25 | # Default-Start: 2 3 4 5 |
26 | # Default-Stop: 0 1 6 | |
27 | # Short-Description: Open vSwitch switch | |
28 | ### END INIT INFO | |
29 | ||
d422c118 | 30 | . /usr/share/openvswitch/scripts/ovs-lib || exit 1 |
43bb5f82 | 31 | . /etc/xensource-inventory |
bc391960 | 32 | test -e /etc/sysconfig/openvswitch && . /etc/sysconfig/openvswitch |
064af421 | 33 | |
43bb5f82 | 34 | case `cat /etc/xensource/network.conf` in |
697e8aa2 JP |
35 | vswitch|openvswitch) |
36 | ;; | |
c6f196a0 JP |
37 | bridge) |
38 | exit 0 | |
39 | ;; | |
697e8aa2 | 40 | *) |
c6f196a0 | 41 | echo "Open vSwitch disabled (/etc/xensource/network.conf is invalid)" >&2 |
697e8aa2 JP |
42 | exit 0 |
43 | ;; | |
44 | esac | |
0313fb2e | 45 | |
f40af195 EJ |
46 | start_ovs_xapi_sync () { |
47 | if daemon_is_running ovs-xapi-sync; then | |
49d9bd5b | 48 | log_success_msg "ovs-xapi-sync is already running" |
f40af195 | 49 | else |
49d9bd5b | 50 | PYTHONPATH=/usr/share/openvswitch/python \ |
f40af195 EJ |
51 | /usr/share/openvswitch/scripts/ovs-xapi-sync \ |
52 | --log-file --pidfile --detach --monitor unix:/var/run/openvswitch/db.sock | |
53 | fi | |
54 | } | |
55 | ||
43bb5f82 | 56 | start () { |
46528f78 | 57 | set ovs_ctl ${1-start} |
43bb5f82 BP |
58 | set "$@" --system-id="$INSTALLATION_UUID" |
59 | set "$@" --system-type="$PRODUCT_BRAND" | |
60 | set "$@" --system-version="$PRODUCT_VERSION-$BUILD_NUMBER" | |
61 | set "$@" --external-id=xs-system-uuid="$INSTALLATION_UUID" | |
62 | set "$@" --daemon-cwd=/var/xen/openvswitch | |
63 | if test X"$FORCE_COREFILES" != X; then | |
49d9bd5b | 64 | set "$@" --force-corefiles="$FORCE_COREFILES" |
55e19919 | 65 | fi |
43bb5f82 | 66 | if test X"$OVSDB_SERVER_PRIORITY" != X; then |
49d9bd5b | 67 | set "$@" --ovsdb-server-priority="$OVSDB_SERVER_PRIORITY" |
55e19919 | 68 | fi |
43bb5f82 | 69 | if test X"$VSWITCHD_PRIORITY" != X; then |
49d9bd5b | 70 | set "$@" --ovs-vswitchd-priority="$VSWITCHD_PRIORITY" |
fea28b07 | 71 | fi |
43bb5f82 | 72 | if test X"$VSWITCHD_MLOCKALL" != X; then |
49d9bd5b | 73 | set "$@" --mlockall="$VSWITCHD_MLOCKALL" |
86a06318 | 74 | fi |
43bb5f82 BP |
75 | if test ! -e /var/run/openvswitch.booted; then |
76 | touch /var/run/openvswitch.booted | |
77 | set "$@" --delete-bridges | |
2e8a4c31 | 78 | fi |
87378a87 | 79 | set "$@" $OVS_CTL_OPTS |
43bb5f82 | 80 | "$@" |
2e8a4c31 | 81 | |
f40af195 | 82 | start_ovs_xapi_sync |
63920cb9 | 83 | |
46528f78 | 84 | ovs_ctl --protocol=gre enable-protocol |
df09921d | 85 | |
bc391960 | 86 | touch /var/lock/subsys/openvswitch |
064af421 BP |
87 | } |
88 | ||
c002dde7 BP |
89 | force_reload_kmod () { |
90 | start force-reload-kmod | |
91 | ||
92 | # Restart the high-availability daemon if it is running. Otherwise | |
93 | # it loses its heartbeat and reboots the system after a few minutes. | |
94 | if pidof xhad >/dev/null && test -e /etc/xensource/xhad.conf; then | |
49d9bd5b SF |
95 | PATH=$PATH:/opt/xensource/xha |
96 | action "Stopping HA daemon" ha_stop_daemon | |
97 | action "Starting HA daemon" ha_start_daemon | |
c002dde7 | 98 | fi |
f40af195 EJ |
99 | |
100 | action "Stopping ovs-xapi-sync" stop_daemon ovs-xapi-sync | |
101 | action "Starting ovs-xapi-sync" start_ovs_xapi_sync | |
c002dde7 BP |
102 | } |
103 | ||
43bb5f82 | 104 | stop () { |
46528f78 | 105 | ovs_ctl stop |
43bb5f82 | 106 | stop_daemon ovs-xapi-sync |
bc391960 | 107 | rm -f /var/lock/subsys/openvswitch |
064af421 BP |
108 | } |
109 | ||
aad12c5f GS |
110 | restart () { |
111 | if [ "$1" = "--save-flows=yes" ]; then | |
112 | stop_daemon ovs-xapi-sync | |
113 | start restart | |
114 | else | |
115 | stop | |
116 | start | |
117 | fi | |
118 | } | |
119 | ||
43bb5f82 | 120 | case $1 in |
064af421 | 121 | start) |
064af421 BP |
122 | start |
123 | ;; | |
124 | stop) | |
125 | stop | |
126 | ;; | |
127 | restart) | |
aad12c5f GS |
128 | shift |
129 | restart "$@" | |
064af421 | 130 | ;; |
210374eb | 131 | reload|force-reload) |
43bb5f82 | 132 | # The main OVS daemons keep up-to-date, but ovs-xapi-sync needs help. |
a256b6e5 EJ |
133 | if daemon_is_running ovs-xapi-sync; then |
134 | action "Configuring Open vSwitch external IDs" \ | |
135 | ovs-appctl -t ovs-xapi-sync flush-cache | |
43bb5f82 | 136 | fi |
064af421 | 137 | ;; |
064af421 | 138 | status) |
46528f78 | 139 | ovs_ctl status && daemon_status ovs-xapi-sync |
064af421 BP |
140 | ;; |
141 | version) | |
46528f78 | 142 | ovs_ctl version |
064af421 | 143 | ;; |
f7a122fc | 144 | force-reload-kmod) |
c002dde7 | 145 | force_reload_kmod |
f7a122fc | 146 | ;; |
064af421 | 147 | help) |
210374eb | 148 | printf "openvswitch [start|stop|restart|reload|force-reload|status|version]\n" |
064af421 BP |
149 | ;; |
150 | *) | |
151 | printf "Unknown command: $1\n" | |
152 | exit 1 | |
153 | ;; | |
154 | esac |