]>
Commit | Line | Data |
---|---|---|
064af421 BP |
1 | #!/bin/bash |
2 | # | |
22c75d59 | 3 | # openvswitch-xapi-update |
064af421 BP |
4 | # |
5 | # chkconfig: 2345 95 01 | |
22c75d59 | 6 | # description: Update Open vSwitch configuration from XAPI database at boot |
064af421 | 7 | |
e0edde6f | 8 | # Copyright (C) 2009, 2010 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-xapi-update | |
23 | # Required-Start: $network $remote_fs | |
24 | # Required-Stop: $network | |
25 | # Default-Start: 3 5 | |
26 | # Default-Stop: | |
27 | # Short-Description: openvswitch-xapi-update | |
28 | # Description: reconfigures Open vSwitch based on XAPI configuration | |
29 | ### END INIT INFO | |
064af421 BP |
30 | |
31 | . /etc/init.d/functions | |
32 | ||
064af421 | 33 | function do_host_call { |
22c75d59 | 34 | xe host-call-plugin host-uuid="$INSTALLATION_UUID" plugin="openvswitch-cfg-update" fn="update" >/dev/null |
064af421 BP |
35 | } |
36 | ||
37 | function start { | |
38 | if [ ! -f /etc/xensource-inventory ]; then | |
22c75d59 | 39 | printf "openvswitch-xapi-update ERROR: XenSource inventory not present in /etc/xensource-inventory\n" |
064af421 BP |
40 | exit 1 |
41 | fi | |
594329e5 EJ |
42 | |
43 | if test -e /etc/xensource/network.conf; then | |
44 | NETWORK_MODE=$(cat /etc/xensource/network.conf) | |
45 | fi | |
46 | ||
47 | case ${NETWORK_MODE:=openvswitch} in | |
48 | vswitch|openvswitch) | |
49 | ;; | |
50 | bridge) | |
51 | exit 0 | |
52 | ;; | |
53 | *) | |
54 | echo "Open vSwitch disabled (/etc/xensource/network.conf is invalid)" >&2 | |
55 | exit 0 | |
56 | ;; | |
57 | esac | |
58 | ||
064af421 BP |
59 | source /etc/xensource-inventory |
60 | action "Updating configuration" do_host_call | |
61 | } | |
62 | ||
63 | case "$1" in | |
64 | start) | |
65 | start | |
66 | ;; | |
67 | stop) | |
68 | # Nothing to do here. | |
69 | ;; | |
70 | restart) | |
71 | start | |
72 | ;; | |
73 | help) | |
22c75d59 | 74 | printf "openvswitch-xapi-update [start|stop|restart]\n" |
064af421 BP |
75 | ;; |
76 | *) | |
77 | printf "Unknown command: $1\n" | |
78 | exit 1 | |
79 | ;; | |
80 | esac |