]> git.ipfire.org Git - people/ms/network.git/blobdiff - src/header-config
hooks: Add HOOK_UNIQUE which stops us from creating multiple instances
[people/ms/network.git] / src / header-config
index baeca5e3340daa79fab82ecff438b10e63d18c04..c6a775c5ea11fcdd2d3620836233d849083b5d99 100644 (file)
 #                                                                             #
 ###############################################################################
 
+# Allow only one instance of this hook
+HOOK_UNIQUE="true"
+
 hook_new() {
        local zone="${1}"
        shift
 
+       # Check if we are allowed to have multiple configurations of $HOOK
+       if enabled HOOK_UNIQUE && zone_config_hook_is_configured "${zone}" "${HOOK}"; then
+               error "You can only have one configuration of type ${HOOK}"
+               return ${EXIT_CONF_ERROR}
+       fi
+
        local id=$(zone_config_get_new_id ${zone})
        log DEBUG "ID for the config is: ${id}"