]> git.ipfire.org Git - people/ms/network.git/commitdiff
zone: Send systemd updates on hotplug events
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 6 Sep 2014 15:15:25 +0000 (17:15 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 6 Sep 2014 15:15:25 +0000 (17:15 +0200)
src/functions/functions.zone
src/network
src/systemd/network@.service.in
src/udev/network-hotplug

index 55ca681dea2b88346ae4e6fd0dc9db152d5145b7..c6c9f38874d9f0c28ab0532b24cdf57a9da802db 100644 (file)
@@ -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}
index 336e9c38e5c7bd35dccb011c278b4f9be6cd41d1..d6a0817ff3be746f354bf43346b331ff750fea17 100644 (file)
@@ -524,7 +524,7 @@ function cli_zone() {
 
                # Action aliases
                case "${action}" in
-                       start)
+                       start|reload)
                                action="up"
                                ;;
                        stop)
index 14da23df1297acb6f919ff971943f93b35400e02..340b19657f57af2c8208ee10930cc8431d6a1c48 100644 (file)
@@ -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
index 09ecc0c498ef86d73f8e137bc16e4c143836287b..246812511970f13b40919d5c3b27a4d059aa6cf2 100644 (file)
@@ -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
                ;;