@@ -29,6 +29,9 @@ if ! [ -x "${DAEMON}" ] ; then
2929 exit 0
3030fi
3131
32+ # Exit if we aren't running on Xen
33+ grep hypervisor /proc/cpuinfo > /dev/null || exit 0
34+
3235# Read configuration variable file if it is present
3336if [ -r /etc/default/${NAME} ] ; then
3437 . /etc/default/${NAME}
@@ -48,21 +51,34 @@ SUBSYS_FILE="/var/run/lock/xcp-networkd"
4851case " ${1} " in
4952start)
5053 log_daemon_msg " Starting ${DESC} " ${NAME}
51- # Copied from the XenServer openvswitch init script.
52- # xcp-networkd gets confused if it sees the bridges already
53- # present and decides that nothing needs to be done, thus
54- # it doesn't bring up eth0 & co.
55- if [ ! -e /var/run/xcp-networkd.booted ]; then
56- touch /var/run/xcp-networkd.booted
57- for bridge in $( /usr/bin/ovs-vsctl list-br) ; do
58- /usr/bin/ovs-vsctl --no-wait --timeout=5 del-br $bridge
59- done
60- fi
61-
54+
55+ # Make sure network.conf exists
6256 if [ ! -e /etc/xcp/network.conf ]; then
6357 echo " bridge" > /etc/xcp/network.conf
6458 fi
6559
60+ # To run if we are in openvswitch mode
61+ if [ ` cat /etc/xcp/network.conf` == " openvswitch" ]; then
62+
63+ # Fail if openvswitch_mod is not loaded
64+ if [ ` lsmod | grep openvswitch_mod > /dev/null` ]; then
65+ log_failure_msg " cannot start xcp-networkd: openvswitch_mod not loaded."
66+ exit 1
67+ fi
68+
69+ # Copied from the XenServer openvswitch init script.
70+ # xcp-networkd gets confused if it sees the bridges already
71+ # present and decides that nothing needs to be done, thus
72+ # it doesn't bring up eth0 & co.
73+ if [ ! -e /var/run/xcp-networkd.booted ]; then
74+ touch /var/run/xcp-networkd.booted
75+ for bridge in $( /usr/bin/ovs-vsctl list-br) ; do
76+ /usr/bin/ovs-vsctl --no-wait --timeout=5 del-br $bridge
77+ done
78+ fi
79+
80+ fi # openvswitch
81+
6682 if [ -e ${SUBSYS_FILE} ]; then
6783 if [ -e ${PIDFILE} -a -e /proc/` cat ${PIDFILE} ` ] ; then
6884 log_failure_msg " ${NAME} is already running."
0 commit comments