From: Michael Tremer Date: Tue, 6 Feb 2018 13:43:38 +0000 (+0000) Subject: ipv6-static: Remove shell switches to define address and prefix X-Git-Tag: 010~161 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=111328cdf6b81a30309f82ec430aaf28cc990212;p=network.git ipv6-static: Remove shell switches to define address and prefix Signed-off-by: Michael Tremer --- diff --git a/src/hooks/configs/ipv6-static b/src/hooks/configs/ipv6-static index 273c201a..ca6cc5ba 100644 --- a/src/hooks/configs/ipv6-static +++ b/src/hooks/configs/ipv6-static @@ -36,19 +36,41 @@ hook_check_config_settings() { hook_parse_cmdline() { while [ $# -gt 0 ]; do case "${1}" in - --address=*) - ADDRESS=${1#--address=} - ;; - --prefix=*) - PREFIX=${1#--prefix=} - ;; --gateway=*) GATEWAY=${1#--gateway=} ;; + *:*/*) + ADDRESS=$(ip_split_prefix "${1}") + PREFIX=$(ip_get_prefix "${1}") + ;; + *) + error "Invalid argument: ${1}" + return ${EXIT_ERROR} + ;; esac shift done + if ! isset ADDRESS; then + error "You need to pass an address" + return ${EXIT_ERROR} + fi + + if ! isset PREFIX; then + error "You need to pass a prefix" + return ${EXIT_ERROR} + fi + + if ! ipv6_is_valid "${ADDRESS}"; then + error "${ADDRESS} is not a valid IPv6 address" + return ${EXIT_ERROR} + fi + + if ! ipv6_prefix_is_valid "${PREFIX}"; then + error "${PREFIX} is not a valid IPv6 prefix" + return ${EXIT_ERROR} + fi + 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}