]> git.ipfire.org Git - people/stevee/network.git/blobdiff - src/header-zone
header-zone: refactor hook_config_destroy
[people/stevee/network.git] / src / header-zone
index c445d55fbf7666e6fc706a3cfb5a63ef0bd1de2e..fdd6e51051bad464f6dce7eb38088573f70bfa15 100644 (file)
@@ -206,7 +206,22 @@ hook_config_new() {
 }
 
 hook_config_destroy() {
-       hook_config_cmd "destroy" "$@"
+       assert [ $# -eq 2 ]
+       local zone=${1}
+       # The id must be the id and not the hid.
+       local id=${2}
+
+       shift 2
+
+       # Check if we get a valid id
+       if ! zone_config_id_is_valid ${zone} ${id}; then
+               log ERROR "ID: ${id} is not a valid id for zone ${zone}"
+       fi
+
+       local hook=$(zone_config_get_hook_from_id ${zone}  ${id})
+       assert isset hook
+
+       hook_config_cmd "destroy" "${zone}" "${hook}" "${hook}.${id}" "$@"
 }
 
 hook_config_edit() {