summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2014-08-06 13:03:50 (EDT)
committer P. J. McDermott <pj@pehjota.net>2014-08-06 13:03:50 (EDT)
commitaaa5253959c5add2c37d546053071f1707dfc02f (patch)
tree51251ba0b118f53ccd7e7c34f26a91cfd285d07d
parent0e281d0103a636d27bd99b952f873d5b37cdebfe (diff)
Only run udhcpd on interfaces that configure it
-rw-r--r--src.etc/network/functions6
-rw-r--r--src.etc/network/if-up.d/dhcpd14
2 files changed, 12 insertions, 8 deletions
diff --git a/src.etc/network/functions b/src.etc/network/functions
index b74fb91..e5967b7 100644
--- a/src.etc/network/functions
+++ b/src.etc/network/functions
@@ -10,9 +10,7 @@ fi
get_iface_opts()
{
- local opts_start_cb="${1}"
- local opt_cb="${2}"
- local opts_end_cb="${3}"
+ local opt_cb="${1}"
local script=
local opts=
local opt=
@@ -29,13 +27,11 @@ get_iface_opts()
return 0
fi
- ${opts_start_cb}
while read -r opt; do
${opt_cb} ${opt}
done <<-EOF
${opts}
EOF
- ${opts_end_cb}
return 0
}
diff --git a/src.etc/network/if-up.d/dhcpd b/src.etc/network/if-up.d/dhcpd
index 5fcc18e..1f86512 100644
--- a/src.etc/network/if-up.d/dhcpd
+++ b/src.etc/network/if-up.d/dhcpd
@@ -4,11 +4,12 @@
set -eu
+dhcpd_enabled=false
address=
subnet=
gateway=
-dhcpd_opts_start_cb()
+dhcpd_start_config()
{
exec 3>"/var/run/udhcpd.${IFACE}.conf"
printf 'interface %s\n' "${IFACE}" >&3
@@ -24,6 +25,10 @@ dhcpd_opt_cb()
case "${key}" in
dhcpd-*)
+ if ! ${dhcpd_enabled}; then
+ dhcpd_start_config
+ dhcpd_enabled=true
+ fi
key="$(printf '%s\n' "${key#dhcpd-}" | tr '-' '_')"
printf '%s %s\n' "${key}" "${val}" >&3
;;
@@ -39,7 +44,7 @@ dhcpd_opt_cb()
esac
}
-dhcpd_opts_end_cb()
+dhcpd_end_config()
{
printf 'option subnet %s\n' "${subnet}" >&3
if [ "x${gateway}" != 'x' ]; then
@@ -53,4 +58,7 @@ dhcpd_opts_end_cb()
udhcpd -S "/var/run/udhcpd.${IFACE}.conf"
}
-get_iface_opts dhcpd_opts_start_cb dhcpd_opt_cb dhcpd_opts_end_cb
+get_iface_opts dhcpd_opt_cb
+if ${dhcpd_enabled}; then
+ dhcpd_end_config
+fi