done
}
+zone_config_check_same_setting() {
+ # This functions checks if a config hook
+ # with the same setting is already configured for this zone.
+ # Returns True when yes and False when no.
+
+ assert [ $# -eq 4 ]
+
+ local zone=${1}
+ local hook=${2}
+ local key=${3}
+ local value=${4}
+
+ # 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 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}"
+ # Check if the value of the config and the passed value are eqal
+ if [[ "${value}" == "${!key}" ]]; then
+ return ${EXIT_TRUE}
+ fi
+ done
+
+ return ${EXIT_FALSE}
+}
+
zone_config_get_hook() {
assert [ $# -eq 2 ]
exit ${EXIT_CONF_ERROR}
fi
+ if zone_config_check_same_setting "${zone}" "ipv4-static" "ADDRESS" "${ADDRESS}"; then
+ error "An ipv4-static config with the same IPv4 address is already configured"
+ exit ${EXIT_CONF_ERROR}
+ fi
+
if ! isset GATEWAY && zone_is_nonlocal "${zone}"; then
warning "You did not configure a gateway for a non-local zone"
fi
shift
done
+ if zone_config_check_same_setting "${zone}" "ipv6-static" "ADDRESS" "${ADDRESS}"; then
+ error "An ipv6-static config with the same IPv6 address is already configured"
+ exit ${EXIT_CONF_ERROR}
+ fi
+
# Store IPv6 address in small format.
ADDRESS=$(ipv6_format "${ADDRESS}")