From: Jonatan Schlag Date: Wed, 5 Jul 2017 14:19:46 +0000 (+0200) Subject: zone: new function zone_config_get_new_id X-Git-Tag: 009~193 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0afedf0dcf748c7aec50ca74342892c9f93ffce9;p=network.git zone: new function zone_config_get_new_id This functions is needed to implement the new id feature described in #11405 Signed-off-by: Jonatan Schlag Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.zone b/src/functions/functions.zone index f321c2d3..b44d3b5e 100644 --- a/src/functions/functions.zone +++ b/src/functions/functions.zone @@ -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 ]