The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/1787

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
 - Don't start dnsmasq when no IPv4 or IPv6 is configured
 - Don't try to kill dnsmasq or the proxy if there's no pid file
 - Use /etc/default/lxd-bridge instead of /etc/default/lxd

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
From 56b052420057a2e7326c15beaa9f2ec6219b9a81 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Mon, 21 Mar 2016 16:57:50 -0400
Subject: [PATCH] lxd-bridge: Some tweaks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

 - Don't start dnsmasq when no IPv4 or IPv6 is configured
 - Don't try to kill dnsmasq or the proxy if there's no pid file
 - Use /etc/default/lxd-bridge instead of /etc/default/lxd

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd-bridge/lxd-bridge | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/lxd-bridge/lxd-bridge b/lxd-bridge/lxd-bridge
index 67e0880..5bbcef2 100755
--- a/lxd-bridge/lxd-bridge
+++ b/lxd-bridge/lxd-bridge
@@ -28,7 +28,7 @@ LXD_IPV6_NETWORK=""
 LXD_IPV6_NAT="false"
 LXD_IPV6_PROXY="true"
 
-[ ! -f "${distrosysconfdir}/lxd" ] || . "${distrosysconfdir}/lxd"
+[ ! -f "${distrosysconfdir}/lxd-bridge" ] || . "${distrosysconfdir}/lxd-bridge"
 
 use_iptables_lock="-w"
 iptables -w -L -n > /dev/null 2>&1 || use_iptables_lock=""
@@ -141,8 +141,10 @@ start() {
         fi
     done
 
-    # shellcheck disable=SC2086
-    dnsmasq ${LXD_CONFILE_ARG} ${LXD_DOMAIN_ARG} -u "${DNSMASQ_USER}" 
--strict-order --bind-interfaces --pid-file="${varrun}/dnsmasq.pid" 
--dhcp-no-override --except-interface=lo --interface="${LXD_BRIDGE}" 
--dhcp-leasefile="${varlib}/misc/dnsmasq.${LXD_BRIDGE}.leases" 
--dhcp-authoritative ${LXD_IPV4_ARG} ${LXD_IPV6_ARG} || cleanup
+    if [ -n "${LXD_IPV4_ADDR}" ] || [ -n "${LXD_IPV6_ADDR}" ]; then
+        # shellcheck disable=SC2086
+        dnsmasq ${LXD_CONFILE_ARG} ${LXD_DOMAIN_ARG} -u "${DNSMASQ_USER}" 
--strict-order --bind-interfaces --pid-file="${varrun}/dnsmasq.pid" 
--dhcp-no-override --except-interface=lo --interface="${LXD_BRIDGE}" 
--dhcp-leasefile="${varlib}/misc/dnsmasq.${LXD_BRIDGE}.leases" 
--dhcp-authoritative ${LXD_IPV4_ARG} ${LXD_IPV6_ARG} || cleanup
+    fi
 
     if [ "${LXD_IPV6_PROXY}" = "true" ]; then
         lxd-bridge-proxy -addr="[fe80::1%${LXD_BRIDGE}]:3128" &
@@ -177,11 +179,16 @@ stop() {
             ip6tables ${use_iptables_lock} -t nat -D POSTROUTING -s 
${LXD_IPV6_NETWORK} ! -d ${LXD_IPV6_NETWORK} -j MASQUERADE
         fi
 
-        pid=$(cat "${varrun}/dnsmasq.pid" 2>/dev/null) && kill -9 "${pid}"
-        rm -f "${varrun}/dnsmasq.pid"
+        if [ -e "${varrun}/dnsmasq.pid" ]; then
+            pid=$(cat "${varrun}/dnsmasq.pid" 2>/dev/null) && kill -9 "${pid}"
+            rm -f "${varrun}/dnsmasq.pid"
+        fi
+
+        if [ -e "${varrun}/proxy.pid" ]; then
+            pid=$(cat "${varrun}/proxy.pid" 2>/dev/null) && kill -9 "${pid}"
+            rm -f "${varrun}/proxy.pid"
+        fi
 
-        pid=$(cat "${varrun}/proxy.pid" 2>/dev/null) && kill -9 "${pid}"
-        rm -f "${varrun}/proxy.pid"
         # if ${LXD_BRIDGE} has attached interfaces, don't destroy the bridge
         ls /sys/class/net/${LXD_BRIDGE}/brif/* > /dev/null 2>&1 || ip link 
delete "${LXD_BRIDGE}"
     fi
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to