]> git.ipfire.org Git - people/ms/network.git/commitdiff
ipv4-static: create hook_parse_cmdline function
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Wed, 19 Jul 2017 08:52:38 +0000 (10:52 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 19 Jul 2017 17:09:49 +0000 (19:09 +0200)
This patch just split the parsing of the cmd line
into a separate function to allowing an edit with the generic hook_edit function.

Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/hooks/configs/ipv4-static

index c39520048da51264dfc0f197c3b58901a21317eb..36629e0f5c7147b5004139a764ae52c51cc241a5 100644 (file)
@@ -35,12 +35,9 @@ hook_check_config_settings() {
        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}")"
@@ -105,6 +102,18 @@ hook_new() {
        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
 
        zone_config_settings_write "${zone}" "${HOOK}"