Update primary code license to Apache 2.0.
[cascardo/ovs.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 test -e /etc/sysconfig/vswitch && . /etc/sysconfig/vswitch
25 VSWITCH_BASE="${VSWITCH_BASE:-/root/vswitch}"
26 VSWITCHD_CONF="${VSWITCHD_CONF:-/etc/ovs-vswitchd.conf}"
27 VSWITCHD_PIDFILE="${VSWITCHD_PIDFILE:-/var/run/ovs-vswitchd.pid}"
28 VSWITCHD_PRIORITY="${VSWITCHD_PRIORITY:--5}"
29 VSWITCHD_LOGFILE="${VSWITCHD_LOGFILE:-/var/log/ovs-vswitchd.log}"
30 VSWITCHD_FILE_LOGLEVEL="${VSWITCHD_FILE_LOGLEVEL:-}"
31 VSWITCHD_SYSLOG_LOGLEVEL="${VSWITCHD_SYSLOG_LOGLEVEL:-WARN}"
32 VSWITCHD_MEMLEAK_LOGFILE="${VSWITCHD_MEMLEAK_LOGFILE:-}"
33 BRCOMPATD_PIDFILE="${BRCOMPATD_PIDFILE:-/var/run/ovs-brcompatd.pid}"
34 BRCOMPATD_PRIORITY="${BRCOMPATD_PRIORITY:--5}"
35 BRCOMPATD_LOGFILE="${BRCOMPATD_LOGFILE:-/var/log/ovs-brcompatd.log}"
36 BRCOMPATD_FILE_LOGLEVEL="${BRCOMPATD_FILE_LOGLEVEL:-}"
37 BRCOMPATD_SYSLOG_LOGLEVEL="${BRCOMPATD_SYSLOG_LOGLEVEL:-WARN}"
38 BRCOMPATD_MEMLEAK_LOGFILE="${BRCOMPATD_MEMLEAK_LOGFILE:-}"
39
40 function do_host_call {
41     xe host-call-plugin host-uuid="$INSTALLATION_UUID" plugin="vswitch-cfg-update" fn="update" >/dev/null
42 }
43
44 function start {
45     if [ ! -f /etc/xensource-inventory ]; then
46         printf "vxwitch-xapi-update ERROR: XenSource inventory not present in /etc/xensource-inventory\n"
47         exit 1
48     fi
49     source /etc/xensource-inventory
50     action "Updating configuration" do_host_call
51 }
52
53 case "$1" in
54     start)
55         start
56         ;;
57     stop)
58         # Nothing to do here.
59         ;;
60     restart)
61         start
62         ;;
63     help)
64         printf "vswitch [start|stop|restart]\n"
65         ;;
66     *)
67         printf "Unknown command: $1\n"
68         exit 1
69         ;;
70 esac