netdev-dpdk: fix mbuf leaks
[cascardo/ovs.git] / xenserver / etc_init.d_openvswitch-xapi-update
1 #!/bin/bash
2 #
3 # openvswitch-xapi-update
4 #
5 # chkconfig: 2345 95 01
6 # description: Update Open vSwitch configuration from XAPI database at boot
7
8 # Copyright (C) 2009, 2010 Nicira, Inc.
9 #
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:
13 #
14 #     http://www.apache.org/licenses/LICENSE-2.0
15 #
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.
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
30
31 . /etc/init.d/functions
32
33 function do_host_call {
34     xe host-call-plugin host-uuid="$INSTALLATION_UUID" plugin="openvswitch-cfg-update" fn="update" >/dev/null
35 }
36
37 function start {
38     if [ ! -f /etc/xensource-inventory ]; then
39         printf "openvswitch-xapi-update ERROR: XenSource inventory not present in /etc/xensource-inventory\n"
40         exit 1
41     fi
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
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)
74         printf "openvswitch-xapi-update [start|stop|restart]\n"
75         ;;
76     *)
77         printf "Unknown command: $1\n"
78         exit 1
79         ;;
80 esac