# #
###############################################################################
-function config_header() {
+config_header() {
local what=${1}
assert isset what
echo
}
-function config_hostname() {
+config_hostname() {
local hostname=${1}
if [ -n "${hostname}" ]; then
fi
}
-function config_domainname() {
+config_domainname() {
local hostname=$(config_hostname)
# Strip off the hostname part and just return
# 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}
+
+ echo "${config##*.}"
+
+}
+
+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:]]}"
+}