[2/6] ports: Change ports settings file to /etc/network/${port}/settings
Message ID | 1497003452-10190-2-git-send-email-jonatan.schlag@ipfire.org |
---|---|
State | Superseded |
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 C145E61C91 for <patchwork@ipfire.org>; Fri, 9 Jun 2017 12:17:51 +0200 (CEST) Received: from mail01.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 76B5C27FA; Fri, 9 Jun 2017 12:17:51 +0200 (CEST) Received: from ipfire.localdomain (dslb-088-073-203-240.088.073.pools.vodafone-ip.de [88.73.203.240]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 8E4D3280A; Fri, 9 Jun 2017 12:17:43 +0200 (CEST) From: Jonatan Schlag <jonatan.schlag@ipfire.org> To: development@lists.ipfire.org, network@lists.ipfire.org Subject: [PATCH 2/6] ports: Change ports settings file to /etc/network/${port}/settings Date: Fri, 9 Jun 2017 12:17:28 +0200 Message-Id: <1497003452-10190-2-git-send-email-jonatan.schlag@ipfire.org> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1497003452-10190-1-git-send-email-jonatan.schlag@ipfire.org> References: <1497003452-10190-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
June 9, 2017, 8:17 p.m. UTC
The configuration of a port was stored in a file called:
/etc/network/${port}
This is bad because it is very hard to add further information
which belong primary not to the configuration to this file.
So we change the settings file to /etc/network/${port}/settings like for the zones.
This make it possible to store other configurations like the color in other files in the directory
/etc/network/${port}.
A workaround to move the config file into the new directory scheme is:
port=p1 && mv /etc/network/ports/${port} /etc/network/ports/${port}-save \
&& mkdir -p /etc/network/ports/${port} \
&& mv /etc/network/ports/${port}-save /etc/network/ports/${port}/settings
where port is the name of the port like p1 or p0.
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
---
src/functions/functions.ports | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
Comments
Hello, for this entire patchset I have a few coding style comments on top of a few questions to clarify a few of the functions for me. On Fri, 2017-06-09 at 12:17 +0200, Jonatan Schlag wrote: > The configuration of a port was stored in a file called: > /etc/network/${port} > This is bad because it is very hard to add further information > which belong primary not to the configuration to this file. > > So we change the settings file to /etc/network/${port}/settings like > for the zones. > > This make it possible to store other configurations like the color in > other files in the directory > /etc/network/${port}. So this is quite a huge change. Ideally we would need to migrate configuration, but given that we are only at alpha stage, it might be okay to break compatibility a bit. I hope I won't regret saying any of this soon. > A workaround to move the config file into the new directory scheme > is: > port=p1 && mv /etc/network/ports/${port} /etc/network/ports/${port}- > save \ > && mkdir -p /etc/network/ports/${port} \ > && mv /etc/network/ports/${port}-save > /etc/network/ports/${port}/settings > > where port is the name of the port like p1 or p0. > > Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org> > --- > src/functions/functions.ports | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/src/functions/functions.ports > b/src/functions/functions.ports > index 40f4eae..b138238 100644 > --- a/src/functions/functions.ports > +++ b/src/functions/functions.ports > @@ -20,12 +20,13 @@ > #################################################################### > ########### > > port_dir() { > - echo "${NETWORK_CONFIG_DIR}/ports" > + local port="${1}" > + echo "${NETWORK_CONFIG_DIR}/ports/${port}" > } > > port_list() { > local port > - for port in $(port_dir)/*; do > + for port in $(port_dir)*; do > port="$(basename "${port}")" > if port_exists "${port}"; then > print "${port}" Not really sure if this works as it should. I think the original version was okay. It would probably be better to not call the port_dir function here at all. > @@ -113,13 +114,13 @@ port_file() { > local port="${1}" > assert isset port > > - echo "$(port_dir)/${port}" > + echo "$(port_dir ${port})/settings" > } > > port_exists() { > local port=${1} > > - [ -f "${NETWORK_CONFIG_DIR}/ports/${port}" ] > + [ -d "${NETWORK_CONFIG_DIR}/ports/${port}" ] > } > > port_get_hook() { > @@ -207,7 +208,7 @@ port_destroy() { > > port_remove "${port}" > > - rm -f $(port_file ${port}) > + rm -rf $(port_dir ${port}) > } > > port_create() { > @@ -263,7 +264,7 @@ port_cmd() { > > ports_get() { > local port > - for port in $(port_dir)/*; do > + for port in $(port_dir)*; do > port=$(basename ${port}) > if port_exists ${port}; then > echo "${port}" Same as above. -Michael