]> git.ipfire.org Git - people/stevee/network.git/commitdiff
zone: Introduce id feature
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Wed, 5 Jul 2017 14:19:49 +0000 (16:19 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 5 Jul 2017 15:10:53 +0000 (17:10 +0200)
When we write a config for the frist time a unique id is generated and appended to the filename.
So it is possible to identify a config clearly.

The variable config is rename to hook because this function takes now
the name of the hook and the id. The name of the config is no more suitable.
If no id is passed we generate one.
This should only happen when we write the file for the first time.

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

index 90d7e115275e99b318e530440111a6fc63a5c4f8..441bf5f8b21945b6e34fd4903fbd65a90f66e22f 100644 (file)
@@ -1216,8 +1216,13 @@ zone_config_settings_write() {
        assert [ $# -ge 2 ]
 
        local zone="${1}"
-       local config="${2}"
-       shift 2
+       local hook="${2}"
+       local id=${3}
+
+       if ! isset id; then
+               id=$(zone_config_get_new_id ${zone})
+               log DEBUG "ID for the config is: ${id}"
+       fi
 
        local args
        if function_exists "hook_check_config_settings"; then
@@ -1225,7 +1230,7 @@ zone_config_settings_write() {
        fi
        list_append args ${HOOK_CONFIG_SETTINGS}
 
-       local path="$(zone_dir "${zone}")/configs/${config}"
+       local path="$(zone_dir "${zone}")/configs/${hook}.${id}"
        settings_write "${path}" ${args}
 }