Merge branch 'master' into next
[sliver-openvswitch.git] / xenserver / etc_init.d_vswitch-xapi-update
1 #!/bin/bash
2 #
3 # vswitch-xapi-update
4 #
5 # chkconfig: 2345 95 01
6 # description: Update vswitch configuration from XAPI database at boot
7
8 # Copyright (C) 2009 Nicira Networks, 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
22 . /etc/init.d/functions
23
24 function do_host_call {
25     xe host-call-plugin host-uuid="$INSTALLATION_UUID" plugin="vswitch-cfg-update" fn="update" >/dev/null
26 }
27
28 function start {
29     if [ ! -f /etc/xensource-inventory ]; then
30         printf "vswitch-xapi-update ERROR: XenSource inventory not present in /etc/xensource-inventory\n"
31         exit 1
32     fi
33     source /etc/xensource-inventory
34     action "Updating configuration" do_host_call
35 }
36
37 case "$1" in
38     start)
39         start
40         ;;
41     stop)
42         # Nothing to do here.
43         ;;
44     restart)
45         start
46         ;;
47     help)
48         printf "vswitch-xapi-update [start|stop|restart]\n"
49         ;;
50     *)
51         printf "Unknown command: $1\n"
52         exit 1
53         ;;
54 esac