From mboxrd@z Thu Jan  1 00:00:00 1970
From: Jonatan Schlag <jonatan.schlag@ipfire.org>
To: network@lists.ipfire.org
Subject: [PATCH 2/6] ports: Change ports settings file to
 /etc/network/${port}/settings
Date: Fri, 09 Jun 2017 12:17:28 +0200
Message-ID: <1497003452-10190-2-git-send-email-jonatan.schlag@ipfire.org>
In-Reply-To: <1497003452-10190-1-git-send-email-jonatan.schlag@ipfire.org>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============6542043661440773193=="
List-Id: <network.lists.ipfire.org>

--===============6542043661440773193==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

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 f=
iles in the directory
/etc/network/${port}.

A workaround to move the config file into the new directory scheme is:
port=3Dp1 && 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(a)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 @@
 ############################################################################=
###
=20
 port_dir() {
-	echo "${NETWORK_CONFIG_DIR}/ports"
+	local port=3D"${1}"
+	echo "${NETWORK_CONFIG_DIR}/ports/${port}"
 }
=20
 port_list() {
 	local port
-	for port in $(port_dir)/*; do
+	for port in $(port_dir)*; do
 		port=3D"$(basename "${port}")"
 		if port_exists "${port}"; then
 			print "${port}"
@@ -113,13 +114,13 @@ port_file() {
 	local port=3D"${1}"
 	assert isset port
=20
-	echo "$(port_dir)/${port}"
+	echo "$(port_dir ${port})/settings"
 }
=20
 port_exists() {
 	local port=3D${1}
=20
-	[ -f "${NETWORK_CONFIG_DIR}/ports/${port}" ]
+	[ -d "${NETWORK_CONFIG_DIR}/ports/${port}" ]
 }
=20
 port_get_hook() {
@@ -207,7 +208,7 @@ port_destroy() {
=20
 	port_remove "${port}"
=20
-	rm -f $(port_file ${port})
+	rm -rf $(port_dir ${port})
 }
=20
 port_create() {
@@ -263,7 +264,7 @@ port_cmd() {
=20
 ports_get() {
 	local port
-	for port in $(port_dir)/*; do
+	for port in $(port_dir)*; do
 		port=3D$(basename ${port})
 		if port_exists ${port}; then
 			echo "${port}"
--=20
2.6.3


--===============6542043661440773193==--