# with the same setting is already configured for this zone.
# Returns True when yes and False when no.
- assert [ $# -eq 4 ]
+ assert [ $# -eq 5 ]
local zone=${1}
local hook=${2}
- local key=${3}
- local value=${4}
+ local id=${3}
+ local key=${4}
+ local value=${5}
# The key should be local for this function
local ${key}
local config
for config in $(zone_configs_list ${zone}); do
+ # Check if the config is eqal with the config we want to edit, when continue
+ if [[ "${config}" = "${hook}.${id}" ]]; then
+ continue
+ fi
+
# Check if the config is from the given hook, when not continue
if [[ $(zone_config_get_hook "${zone}" "${config}") != ${hook} ]]; then
continue
fi
+
# Get the value of the key for a given function
zone_config_settings_read "${zone}" "${config}" \
--ignore-superfluous-settings "${key}"
local hook="${2}"
local id=${3}
- if ! isset id; then
- id=$(zone_config_get_new_id ${zone})
- log DEBUG "ID for the config is: ${id}"
- fi
+ assert isset id
local args
if function_exists "hook_check_config_settings"; then
local zone="${1}"
shift
+ local id=$(zone_config_get_new_id ${zone})
+ log DEBUG "ID for the config is: ${id}"
+
# Parse command line arguments
- if ! hook_parse_cmdline "$@"; then
+ if ! hook_parse_cmdline "${id}" "$@"; then
+ # Return an error if the parsing of the cmd line fails
return ${EXIT_ERROR}
fi
return ${EXIT_ERROR}
fi
- if ! hook_parse_cmdline "$@"; then
+ if ! hook_parse_cmdline "${id}" "$@"; then
# Return an error if the parsing of the cmd line fails
return ${EXIT_ERROR}
fi
}
hook_parse_cmdline() {
+ local id="${1}"
+ shift
+
while [ $# -gt 0 ]; do
case "${1}" in
--enable-ipv6)
return ${EXIT_ERROR}
fi
- if ! hook_parse_cmdline "$@"; then
+ local id=$(zone_config_get_new_id ${zone})
+ log DEBUG "ID for the config is: ${id}"
+
+ if ! hook_parse_cmdline "${id}" "$@"; then
# Return an error if the parsing of the cmd line fails
return ${EXIT_ERROR}
fi
- zone_config_settings_write "${zone}" "${HOOK}"
+ zone_config_settings_write "${zone}" "${HOOK}" "${id}"
exit ${EXIT_OK}
}
}
hook_parse_cmdline() {
+ local id="${1}"
+ shift
+
local arg
while read arg; do
return ${EXIT_ERROR}
fi
- if ! hook_parse_cmdline "$@"; then
+ local id=$(zone_config_get_new_id ${zone})
+ log DEBUG "ID for the config is: ${id}"
+
+ if ! hook_parse_cmdline "${id}" "$@"; then
# Return an error if the parsing of the cmd line fails
return ${EXIT_ERROR}
fi
- zone_config_settings_write "${zone}" "${HOOK}"
+ zone_config_settings_write "${zone}" "${HOOK}" "${id}"
exit ${EXIT_OK}
}
}
hook_parse_cmdline() {
+ local id="${1}"
+ shift
+
while [ $# -gt 0 ]; do
case "${1}" in
--dns-server=*)
return ${EXIT_ERROR}
fi
- if ! hook_parse_cmdline "$@"; then
+ local id=$(zone_config_get_new_id ${zone})
+ log DEBUG "ID for the config is: ${id}"
+
+ if ! hook_parse_cmdline "${id}" "$@"; then
# Return an error if the parsing of the cmd line fails
return ${EXIT_ERROR}
fi
- zone_config_settings_write "${zone}" "${HOOK}"
+ zone_config_settings_write "${zone}" "${HOOK}" "${id}"
exit ${EXIT_OK}
}