]> git.ipfire.org Git - people/ms/network.git/commitdiff
zone: new function zone_config_get_new_id
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Wed, 5 Jul 2017 14:19:46 +0000 (16:19 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 5 Jul 2017 15:09:34 +0000 (17:09 +0200)
This functions is needed to implement the new id feature
described in #11405

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

index f321c2d3d03e04b625ee001844b5a7602547e60f..b44d3b5edfe20d569e19563ca5badbb4cf510a14 100644 (file)
@@ -992,6 +992,24 @@ zone_configs_list() {
        done
 }
 
+zone_config_get_new_id() {
+       # This functions returns the next free id for a zone
+
+       assert [ $# -eq 1 ]
+       local zone=${1}
+
+       local zone_path=$(zone_dir ${zone})
+       local i=0
+
+       while true; do
+               if [ ! -f ${zone_path}/configs/*.${i} ]; then
+                       echo "${i}"
+                       return ${EXIT_OK}
+               fi
+               (( i++ ))
+       done
+}
+
 zone_config_get_hook() {
        assert [ $# -eq 2 ]