]> git.ipfire.org Git - people/stevee/network.git/blobdiff - src/hooks/configs/pppoe-server
network fix parameter passing when using ""
[people/stevee/network.git] / src / hooks / configs / pppoe-server
index 22e0906de2a2a1bd72ed8b77d40bcf2a4b32930f..7021be2a973c60440a592a5e31dc573a5d173856 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=*)
@@ -73,24 +65,24 @@ hook_new() {
                                done
                                ;;
                        --max-sessions=*)
-                               MAX_SESSIONS=$(cli_get_val ${1})
+                               MAX_SESSIONS=$(cli_get_val "${1}")
                                if ! isinteger ${MAX_SESSIONS} || ! [ ${MAX_SESSIONS} -ge 0 ]; then
                                        error "Invalid value for '--max-session'. This value must be an integer greate or eqal zero."
                                        exit ${EXIT_ERROR}
                                fi
                                ;;
                        --mtu=*)
-                               MTU=$(cli_get_val ${1})
+                               MTU=$(cli_get_val "${1}")
                                if ! mtu_is_valid "ipv4" ${MTU}; then
                                        error "Invalid value for '--mtu'. Cannot be larger then 9000 or smaller than 576"
                                        exit ${EXIT_ERROR}
                                fi
                                ;;
                        --service-name=*)
-                               SERVICE_NAME=$(cli_get_val ${1})
+                               SERVICE_NAME=$(cli_get_val "${1}")
                                ;;
                        --subnet=*)
-                               SUBNET=$(cli_get_val ${1})
+                               SUBNET=$(cli_get_val "${1}")
                                if ! ipv4_net_is_valid "${SUBNET}"; then
                                        error "Invalid IPv4 Subnet ${SUBNET}."
                                        exit ${EXIT_ERROR}
@@ -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}"