]> git.ipfire.org Git - people/stevee/network.git/commitdiff
zone: new function zone_config_settings_destroy
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Fri, 14 Jul 2017 12:19:41 +0000 (14:19 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 27 Jul 2017 09:37:48 +0000 (11:37 +0200)
Similar to zone_config_settings_write and zone_config_settings_read
this function provides an easy way to delete a config file.

Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.zone

index bba1705575a15f4d3ba064bf9568c76a28f5f7b9..f46fc84f313ad2c20c7b4864ce23cf2472ca3119 100644 (file)
@@ -1287,6 +1287,24 @@ zone_config_settings_write() {
        settings_write "${path}" ${args}
 }
 
+zone_config_settings_destroy() {
+       # This function deletes the config file for a given zone and config
+       assert [ $# -ge 2 ]
+       local zone="${1}"
+       local config="${2}"
+
+       local path="$(zone_dir "${zone}")/configs/${config}"
+
+       # Check if path is valid
+       if [ ! -f ${path} ]; then
+               log ERROR "Path: '${path}' is not valid"
+               return ${EXIT_ERROR}
+       fi
+
+       log DEBUG "Deleting config file ${path}"
+       rm -f "${path}"
+
+}
 zone_port_settings_read() {
        assert [ $# -ge 2 ]