[3/7] zone: add function to avoid multiple configs which are senseless
Message ID | 1499183171-24236-3-git-send-email-jonatan.schlag@ipfire.org |
---|---|
State | Accepted |
Commit | 41f8233d17da3465c0b873ecac40c173972a206e |
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 3D193621AC for <patchwork@ipfire.org>; Tue, 4 Jul 2017 17:46:20 +0200 (CEST) Received: from mail01.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 120621E5B; Tue, 4 Jul 2017 17:46:20 +0200 (CEST) Received: from ipfire.localdomain (dslb-088-073-193-205.088.073.pools.vodafone-ip.de [88.73.193.205]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 24A5627CE; Tue, 4 Jul 2017 17:46:18 +0200 (CEST) From: Jonatan Schlag <jonatan.schlag@ipfire.org> To: network@lists.ipfire.org Subject: [PATCH 3/7] zone: add function to avoid multiple configs which are senseless Date: Tue, 4 Jul 2017 17:46:07 +0200 Message-Id: <1499183171-24236-3-git-send-email-jonatan.schlag@ipfire.org> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1499183171-24236-1-git-send-email-jonatan.schlag@ipfire.org> References: <1499183171-24236-1-git-send-email-jonatan.schlag@ipfire.org> 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 5, 2017, 1:46 a.m. UTC
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
---
src/functions/functions.zone | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
Comments
Perfect coding style here! :) On Tue, 2017-07-04 at 17:46 +0200, Jonatan Schlag wrote: > Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org> > --- > src/functions/functions.zone | 22 ++++++++++++++++++++++ > 1 file changed, 22 insertions(+) > > diff --git a/src/functions/functions.zone > b/src/functions/functions.zone > index 058110d..f2c5ddc 100644 > --- a/src/functions/functions.zone > +++ b/src/functions/functions.zone > @@ -1008,6 +1008,28 @@ zone_config_get_hook() { > print "${HOOK}" > } > > +zone_config_hook_is_configured() { > + # Checks if a zone has already at least one config with the > given hook. > + # Returns True when yes and False when no > + > + assert [ $# -eq 2 ] > + local zone=${1} > + local hook=${2} > + > + local config > + for config in $(zone_configs_list "${zone}"); do > + local config_hook="$(zone_config_get_hook "${zone}" > "${config}")" > + assert isset config_hook > + if [[ ${hook} == ${config_hook} ]]; then > + return ${EXIT_TRUE} > + fi > + > + done > + > + # If we get here the zone has no config with the given hook > + return ${EXIT_FALSE} > +} > + > zone_has_ip() { > device_has_ip $@ > }