[v2,1/5] ports: Change ports settings file to /etc/network/${port}/settings

Submitted by Jonatan Schlag on June 15, 2017, 4:18 p.m.

Details

Message ID 1497543533-5925-1-git-send-email-jonatan.schlag@ipfire.org
State New
Headers show

Commit Message

Jonatan Schlag June 15, 2017, 4:18 p.m.
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 | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/functions/functions.ports b/src/functions/functions.ports
index 952eef9..c6e45d0 100644
--- a/src/functions/functions.ports
+++ b/src/functions/functions.ports
@@ -20,7 +20,8 @@ 
 ###############################################################################
 
 port_dir() {
-	echo "${NETWORK_CONFIG_DIR}/ports"
+	local port="${1}"
+	echo "${NETWORK_CONFIG_DIR}/ports/${port}"
 }
 
 port_list() {
@@ -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() {