From 0afedf0dcf748c7aec50ca74342892c9f93ffce9 Mon Sep 17 00:00:00 2001 From: Jonatan Schlag Date: Wed, 5 Jul 2017 16:19:46 +0200 Subject: [PATCH] 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 --- src/functions/functions.zone | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 ] -- 2.39.2