From: Jonatan Schlag Date: Mon, 17 Jul 2017 15:24:25 +0000 (+0200) Subject: config: add new functions X-Git-Tag: 009~169 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b474c46d4784047487e730050e831c56530ee40;p=network.git config: add new functions This patch add two new functions: config_get_id_from_config() config_get_hook_from_config Signed-off-by: Jonatan Schlag Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.config b/src/functions/functions.config index 854f4907..e11a1c2b 100644 --- a/src/functions/functions.config +++ b/src/functions/functions.config @@ -51,3 +51,23 @@ config_domainname() { # the domain part. print "${hostname#*.}" } + +config_get_id_from_config() { + # This function returns the id for a given config name + # Example 'dhcp.0' => 0 + assert [ $# -eq 1 ] + local config=${1} + + local hook=$(config_get_hook_from_config ${config}) + echo "${config//"${hook}."/}" + +} + +config_get_hook_from_config() { + # This function returns the hook for a given config name + # Example 'dhcp.0' => dhcp + assert [ $# -eq 1 ] + local config=${1} + + echo "${config//.*[[:digit:]]/}" +}