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

index 22e0906de2a2a1bd72ed8b77d40bcf2a4b32930f..b4d2538947c76d45c9e439325aab978fb7e61e71 100644 (file)
@@ -48,15 +48,7 @@ hook_check_config_settings() {
        done
 }
 
-hook_new() {
-       local zone=${1}
-       shift
-
-       if zone_config_hook_is_configured ${zone} "pppoe-server"; then
-               log ERROR "You can configure the pppoe-server hook only once for a zone"
-               return ${EXIT_ERROR}
-       fi
-
+hook_parse_cmdline() {
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --dns-server=*)
@@ -102,6 +94,21 @@ hook_new() {
                esac
                shift
        done
+}
+
+hook_new() {
+       local zone=${1}
+       shift
+
+       if zone_config_hook_is_configured ${zone} "pppoe-server"; then
+               log ERROR "You can configure the pppoe-server 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}"