From mboxrd@z Thu Jan  1 00:00:00 1970
From: Jonatan Schlag <jonatan.schlag@ipfire.org>
To: network@lists.ipfire.org
Subject: [PATCH 1/4] pppoe-server: create hook_parse_cmdline function
Date: Wed, 19 Jul 2017 10:52:35 +0200
Message-ID: <1500454358-6561-2-git-send-email-jonatan.schlag@ipfire.org>
In-Reply-To: <1500454358-6561-1-git-send-email-jonatan.schlag@ipfire.org>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============0357716176467092877=="
List-Id: <network.lists.ipfire.org>

--===============0357716176467092877==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

This patch just split the parsing of the cmd line
into a separate function to allowing an edit with the generic hook_edit funct=
ion.

Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
---
 src/hooks/configs/pppoe-server | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/src/hooks/configs/pppoe-server b/src/hooks/configs/pppoe-server
index 22e0906..b4d2538 100644
--- a/src/hooks/configs/pppoe-server
+++ b/src/hooks/configs/pppoe-server
@@ -48,15 +48,7 @@ hook_check_config_settings() {
 	done
 }
=20
-hook_new() {
-	local zone=3D${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=3D*)
@@ -102,6 +94,21 @@ hook_new() {
 		esac
 		shift
 	done
+}
+
+hook_new() {
+	local zone=3D${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
=20
 	zone_config_settings_write "${zone}" "${HOOK}"
=20
--=20
2.6.3


--===============0357716176467092877==--