From e6fd23fd31b73042e461f3fd70e68a1fff3a9080 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 6 Sep 2014 17:15:25 +0200 Subject: [PATCH] zone: Send systemd updates on hotplug events --- src/functions/functions.zone | 18 ++++++++++++++++++ src/network | 2 +- src/systemd/network@.service.in | 1 + src/udev/network-hotplug | 6 ++++-- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/functions/functions.zone b/src/functions/functions.zone index 55ca681d..c6c9f388 100644 --- a/src/functions/functions.zone +++ b/src/functions/functions.zone @@ -91,6 +91,13 @@ function zone_stop() { service_stop "network@${zone}.service" } +function zone_reload() { + local zone="${1}" + assert zone_exists "${zone}" + + service_reload "network@${zone}.service" +} + function zone_enable() { # This function will enable the zone # with help of systemd. @@ -143,6 +150,17 @@ function zone_is_enabled() { return ${EXIT_FALSE} } +function zone_is_active() { + local zone="${1}" + assert isset zone + + if service_is_active "network@${zone}.service"; then + return ${EXIT_TRUE} + fi + + return ${EXIT_FALSE} +} + function zone_create() { local zone=${1} local hook=${2} diff --git a/src/network b/src/network index 336e9c38..d6a0817f 100644 --- a/src/network +++ b/src/network @@ -524,7 +524,7 @@ function cli_zone() { # Action aliases case "${action}" in - start) + start|reload) action="up" ;; stop) diff --git a/src/systemd/network@.service.in b/src/systemd/network@.service.in index 14da23df..340b1965 100644 --- a/src/systemd/network@.service.in +++ b/src/systemd/network@.service.in @@ -10,6 +10,7 @@ Type=oneshot RemainAfterExit=yes ExecStart=@sbindir@/network zone %I up ExecStop=@sbindir@/network zone %I down +ExecReload=@sbindir@/network zone %I reload [Install] WantedBy=network.target diff --git a/src/udev/network-hotplug b/src/udev/network-hotplug index 09ecc0c4..24681251 100644 --- a/src/udev/network-hotplug +++ b/src/udev/network-hotplug @@ -114,8 +114,10 @@ case "${ACTION}" in # If the zone is already up or enabled for auto-start, # we add the device to the zone. - if zone_is_up "${zone}" || zone_is_enabled "${zone}"; then - zone_up "${zone}" + if zone_is_active "${zone}"; then + zone_reload "${zone}" + elif zone_is_enabled "${zone}"; then + zone_start "${zone}" fi ;; -- 2.39.2