zone: response with an error if a zone is already up or down
Message ID | 1500988437-3732-1-git-send-email-jonatan.schlag@ipfire.org |
---|---|
State | New |
Headers |
Return-Path: <network-bounces@lists.ipfire.org> Received: from mail01.ipfire.org (unknown [172.28.1.200]) by web02.ipfire.org (Postfix) with ESMTP id 0D0A160FCA for <patchwork@ipfire.org>; Tue, 25 Jul 2017 15:14:01 +0200 (CEST) Received: from mail01.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id C052A26FA; Tue, 25 Jul 2017 15:14:00 +0200 (CEST) Received: from ipfire.localdomain (dslb-088-073-218-016.088.073.pools.vodafone-ip.de [88.73.218.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 2C0EC24AC; Tue, 25 Jul 2017 15:13:59 +0200 (CEST) From: Jonatan Schlag <jonatan.schlag@ipfire.org> To: network@lists.ipfire.org Subject: [PATCH] zone: response with an error if a zone is already up or down Date: Tue, 25 Jul 2017 15:13:57 +0200 Message-Id: <1500988437-3732-1-git-send-email-jonatan.schlag@ipfire.org> X-Mailer: git-send-email 2.6.3 X-BeenThere: network@lists.ipfire.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List for the network package <network.lists.ipfire.org> List-Unsubscribe: <http://lists.ipfire.org/mailman/options/network>, <mailto:network-request@lists.ipfire.org?subject=unsubscribe> List-Archive: <http://lists.ipfire.org/pipermail/network/> List-Post: <mailto:network@lists.ipfire.org> List-Help: <mailto:network-request@lists.ipfire.org?subject=help> List-Subscribe: <http://lists.ipfire.org/mailman/listinfo/network>, <mailto:network-request@lists.ipfire.org?subject=subscribe> Errors-To: network-bounces@lists.ipfire.org Sender: "network" <network-bounces@lists.ipfire.org> |
Message
Jonatan Schlag
July 25, 2017, 11:13 p.m. UTC
Fixes: #11368
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
---
src/functions/functions.zone | 13 +++++++++++++
1 file changed, 13 insertions(+)
Comments
Hi, this patch looks logically fine, but I sometimes use the "up" function to reload a zone which is no longer possible. And secondly, I am not sure if "zone_is_active" will return true when systemd has started the script. In that case, the "up" action would be called and assume that everything is up already and therefore never bring up the zone. -Michael On Tue, 2017-07-25 at 15:13 +0200, Jonatan Schlag wrote: > Fixes: #11368 > > Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org> > --- > src/functions/functions.zone | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/src/functions/functions.zone b/src/functions/functions.zone > index 91ce629..eccca3a 100644 > --- a/src/functions/functions.zone > +++ b/src/functions/functions.zone > @@ -369,6 +369,12 @@ zone_up() { > return ${EXIT_ERROR} > fi > > + # Check if the zone is already up > + if zone_is_active ${zone}; then > + log ERROR "Zone ${zone} is already 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." > @@ -405,6 +411,13 @@ zone_down() { > return ${EXIT_ERROR} > fi > > + # Check if the zone is already down > + if ! zone_is_active ${zone}; then > + log ERROR "Zone ${zone} is already down" > + return ${EXIT_ERROR} > + fi > + > + > local hook="$(zone_get_hook "${zone}")" > if [ -z "${hook}" ]; then > error "Config file did not provide any hook."