Import from old repository commit 61ef2b42a9c4ba8e1600f15bb0236765edc2ad45.
[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 # This program is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation, either version 3 of the License, or
13 # (at your option) any later version.
14 #
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
23 . /etc/init.d/functions
24
25 test -e /etc/sysconfig/vswitch && . /etc/sysconfig/vswitch
26 VSWITCH_BASE="${VSWITCH_BASE:-/root/vswitch}"
27 VSWITCHD_CONF="${VSWITCHD_CONF:-/etc/ovs-vswitchd.conf}"
28 VSWITCHD_PIDFILE="${VSWITCHD_PIDFILE:-/var/run/ovs-vswitchd.pid}"
29 VSWITCHD_PRIORITY="${VSWITCHD_PRIORITY:--5}"
30 VSWITCHD_LOGFILE="${VSWITCHD_LOGFILE:-/var/log/ovs-vswitchd.log}"
31 VSWITCHD_FILE_LOGLEVEL="${VSWITCHD_FILE_LOGLEVEL:-}"
32 VSWITCHD_SYSLOG_LOGLEVEL="${VSWITCHD_SYSLOG_LOGLEVEL:-WARN}"
33 VSWITCHD_MEMLEAK_LOGFILE="${VSWITCHD_MEMLEAK_LOGFILE:-}"
34 BRCOMPATD_PIDFILE="${BRCOMPATD_PIDFILE:-/var/run/ovs-brcompatd.pid}"
35 BRCOMPATD_PRIORITY="${BRCOMPATD_PRIORITY:--5}"
36 BRCOMPATD_LOGFILE="${BRCOMPATD_LOGFILE:-/var/log/ovs-brcompatd.log}"
37 BRCOMPATD_FILE_LOGLEVEL="${BRCOMPATD_FILE_LOGLEVEL:-}"
38 BRCOMPATD_SYSLOG_LOGLEVEL="${BRCOMPATD_SYSLOG_LOGLEVEL:-WARN}"
39 BRCOMPATD_MEMLEAK_LOGFILE="${BRCOMPATD_MEMLEAK_LOGFILE:-}"
40
41 function do_host_call {
42     xe host-call-plugin host-uuid="$INSTALLATION_UUID" plugin="vswitch-cfg-update" fn="update" >/dev/null
43 }
44
45 function start {
46     if [ ! -f /etc/xensource-inventory ]; then
47         printf "vxwitch-xapi-update ERROR: XenSource inventory not present in /etc/xensource-inventory\n"
48         exit 1
49     fi
50     source /etc/xensource-inventory
51     action "Updating configuration" do_host_call
52 }
53
54 case "$1" in
55     start)
56         start
57         ;;
58     stop)
59         # Nothing to do here.
60         ;;
61     restart)
62         start
63         ;;
64     help)
65         printf "vswitch [start|stop|restart]\n"
66         ;;
67     *)
68         printf "Unknown command: $1\n"
69         exit 1
70         ;;
71 esac