fi
}
-hook_new() {
- local zone="${1}"
- assert zone_exists "${zone}"
- shift
-
+hook_parse_cmdline() {
local arg
+
while read -r arg; do
local key="$(cli_get_key "${arg}")"
local val="$(cli_get_val "${arg}")"
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
+}
+
+hook_new() {
+ local zone="${1}"
+ shift
+
+ assert zone_exists "${zone}"
+
+ if ! hook_parse_cmdline $@; then
+ # Return an error if the parsing of the cmd line fails
+ return ${EXIT_ERROR}
+ fi
- # XXX maybe we can add some hashing to identify a configuration again
- zone_config_settings_write "${zone}" "${HOOK}.$(uuid)"
+ zone_config_settings_write "${zone}" "${HOOK}"
exit ${EXIT_OK}
}
error "Zone '${zone}' doesn't exist."
exit ${EXIT_ERROR}
fi
-
+
+ # Remove routing information from database.
+ db_delete "${zone}/ipv4"
+
zone_config_settings_read "${zone}" "${config}"
ip_address_del ${zone} ${ADDRESS}/${PREFIX}