]> git.ipfire.org Git - network.git/commitdiff
ipv6-auto: create hook_parse_cmdline function
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Wed, 19 Jul 2017 08:52:37 +0000 (10:52 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 19 Jul 2017 17:09:47 +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/ipv6-auto

index c36279757c86efeaea4ca3db3995e7f00df9c73d..375e585d3ad834c9a4e3dc84d817d9134218d6a5 100644 (file)
@@ -30,14 +30,8 @@ hook_check_config_settings() {
        assert isbool PRIVACY_EXTENSIONS
 }
 
-hook_new() {
-       local zone="${1}"
-       shift
-
-       if zone_config_hook_is_configured ${zone} "ipv6-auto"; then
-               log ERROR "You can configure the ipv6-auto hook only once for a zone"
-               return ${EXIT_ERROR}
-       fi
+hook_parse_cmdline() {
+       local arg
 
        while read arg; do
                case "${arg}" in
@@ -52,6 +46,21 @@ hook_new() {
                                ;;
                esac
        done <<< "$(args $@)"
+}
+
+hook_new() {
+       local zone="${1}"
+       shift
+
+       if zone_config_hook_is_configured ${zone} "ipv6-auto"; then
+               log ERROR "You can configure the ipv6-auto hook only once for a zone"
+               return ${EXIT_ERROR}
+       fi
+
+       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}"