]> git.ipfire.org Git - people/ms/network.git/commitdiff
Always destroy zones immediately
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 15 Aug 2017 21:25:53 +0000 (21:25 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 15 Aug 2017 21:25:53 +0000 (21:25 +0000)
The delayed destroyal does not make much sense when this is not
implemented for ports, etc.

Fixes #11434

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.zone
src/network

index 1eb492f5ad3aa3677e77cddc3ca5dc2177cb376e..b79127a2106e78ca8e57d412877f77604fab3b54 100644 (file)
@@ -244,7 +244,7 @@ zone_new() {
        # Maybe the zone new hook did not exit correctly.
        # If this is the case we remove the created zone immediately.
        if [ "${ret}" != "${EXIT_OK}" ]; then
-               zone_destroy_now "${zone}"
+               zone_destroy "${zone}"
                return ${EXIT_ERROR}
        fi
 
@@ -264,12 +264,6 @@ zone_edit() {
                return ${EXIT_ERROR}
        fi
 
-       # Check if the zone is tagged for removal.
-       if zone_has_destroy_tag ${zone}; then
-               error "You cannot edit a zone that is tagged for removal."
-               return ${EXIT_ERROR}
-       fi
-
        local hook="$(zone_get_hook "${zone}")"
        if [ -z "${hook}" ]; then
                error "Config file did not provide any hook."
@@ -291,7 +285,6 @@ zone_rename() {
        local name="${2}"
 
        assert zone_exists "${zone}"
-       assert not zone_has_destroy_tag "${zone}"
        assert not zone_exists "${name}"
 
        # The zone must be shut down before, is then renamed and
@@ -327,34 +320,19 @@ zone_rename() {
 
 zone_destroy() {
        local zone="${1}"
-       assert zone_exists "${zone}"
-
-       # Make the zone for removal.
-       touch "$(zone_dir "${zone}")/.destroy"
-
-       log INFO "Zone '${zone}' has been tagged for removal."
-}
-
-zone_has_destroy_tag() {
-       local zone="${1}"
-       assert zone_exists "${zone}"
-
-       [ -e "$(zone_dir "${zone}")/.destroy" ]
-}
 
-# This function will remove the given zone
-# RIGHT NOW. Use zone_destroy to remove it
-# at the next status change.
-zone_destroy_now() {
-       local zone="${1}"
-       assert zone_exists "${zone}"
+       # Cannot delete a zone that does not exist
+       if ! zone_exists "${zone}"; then
+               log ERROR "Zone ${zone} does not exist"
+               return ${EXIT_ERROR}
+       fi
 
-       log INFO "Removing zone '${zone}' right now."
+       log INFO "Destroying zone ${zone}"
 
        # Force the zone down.
        zone_is_active "${zone}" && zone_stop "${zone}"
 
-       # Disable zone.
+       # Disable zone auto-start
        zone_disable "${zone}"
 
        rm -rf "$(zone_dir "${zone}")"
@@ -369,12 +347,6 @@ zone_up() {
                return ${EXIT_ERROR}
        fi
 
-       # Check if a zone has got the remove tag.
-       if zone_has_destroy_tag ${zone}; then
-               error "Cannot bring up any zone which is to be removed."
-               return ${EXIT_ERROR}
-       fi
-
        local hook="$(zone_get_hook "${zone}")"
        if [ -z "${hook}" ]; then
                error "Config file did not provide any hook."
@@ -424,11 +396,6 @@ zone_down() {
 
        # Execute all triggers after the zone went down
        triggers_execute_all "down" ZONE="${zone}"
-
-       # Remove the zone, if it has got a remove tag.
-       if zone_has_destroy_tag "${zone}"; then
-               zone_destroy_now "${zone}"
-       fi
 }
 
 zone_status() {
@@ -453,11 +420,6 @@ zone_status() {
        fi
 
        hook_zone_exec "${hook}" "status" "${zone}" "$@"
-
-       # Show that the zone it to be removed soon.
-       if zone_has_destroy_tag ${zone}; then
-               warning "This zone is tagged for removal."
-       fi
 }
 
 zone_identify() {
index 547bab1b594cc2f25fd7632670bb8218f19ae9e9..711cf75f796b7f06c8ae9eba9611f224c1e01c54 100644 (file)
@@ -720,12 +720,6 @@ cli_zone_rename() {
                exit ${EXIT_ERROR}
        fi
 
-       # Destroyed zones cannot be renamed
-       if zone_has_destroy_tag "${zone}"; then
-               error "Zone ${zone} is about to be destroyed and cannot be renamed"
-               exit ${EXIT_ERROR}
-       fi
-
        # Check if a zone with the new name already exists
        if zone_exists "${name}"; then
                error "Zone ${name} already exists"