From mboxrd@z Thu Jan  1 00:00:00 1970
From: Stefan Schantl <stefan.schantl@ipfire.org>
To: network@lists.ipfire.org
Subject: [PATCHv2] Fix hook for static address configuration.
Date: Sat, 11 Aug 2018 21:21:27 +0200
Message-ID: <20180811192127.14322-1-stefan.schantl@ipfire.org>
In-Reply-To: <dd0ef20984d2bafc855c946dacefd4ccb70b1d63.camel@ipfire.org>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============1313682393601587025=="
List-Id: <network.lists.ipfire.org>

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

Add the required hook_new function and "id" information which have been
introduced in earlier commits to make this hook work again.

Signed-off-by: Stefan Schantl <stefan.schantl(a)ipfire.org>
---
 src/hooks/configs/static | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/hooks/configs/static b/src/hooks/configs/static
index 91bba8a..23ae2d8 100644
--- a/src/hooks/configs/static
+++ b/src/hooks/configs/static
@@ -52,6 +52,8 @@ hook_check_config_settings() {
=20
 hook_parse_cmdline() {
 	local protocol
+	local id=3D"${1}"
+	shift
=20
 	while [ $# -gt 0 ]; do
 		case "${1}" in
@@ -153,12 +155,29 @@ hook_parse_cmdline() {
 	fi
=20
 	# Check any conflicts
-	if zone_config_check_same_setting "${zone}" "static" "ADDRESS" "${ADDRESS}"=
; then
+	if zone_config_check_same_setting "${zone}" "static" "${id}" "ADDRESS" "${A=
DDRESS}"; then
 		error "A static configuration with the same address is already configured"
 		return ${EXIT_CONF_ERROR}
 	fi
 }
=20
+hook_new() {
+	local zone=3D"${1}"
+	shift
+
+	local id=3D$(zone_config_get_new_id ${zone})
+	log DEBUG "ID for the config is: ${id}"
+
+	if ! hook_parse_cmdline "${id}" "$@"; then
+		# Return an error if the parsing of the cmd line fails
+		return ${EXIT_ERROR}
+	fi
+
+	zone_config_settings_write "${zone}" "${HOOK}" "${id}"
+
+	exit ${EXIT_OK}
+}
+
 hook_up() {
 	local zone=3D"${1}"
 	local config=3D"${2}"
--=20
2.17.1


--===============1313682393601587025==--