# #
###############################################################################
-HOOK_COMMANDS_CONFIG="hook_create hook_down hook_status hook_up"
+HOOK_COMMANDS_CONFIG="hook_create hook_down hook_status hook_remove hook_up"
HOOK_COMMANDS_PORT="hook_create hook_down hook_edit hook_hotplug \
hook_hotplug_rename hook_info hook_status hook_up"
return ${ret}
}
+function hook_list() {
+ local type="${1}"
+
+ local dir="$(hook_dir "${type}")"
+ assert isset dir
+
+ local hook
+ for hook in ${dir}/*; do
+ hook="$(basename "${hook}")"
+
+ if hook_exists "${type}" "${hook}"; then
+ echo "${hook}"
+ fi
+ done
+}
+
function config_get_hook() {
local config=${1}
hook_exists zone $@
}
-function hook_zone_config_exists() {
- local hook_zone=${1}
- local hook_config=${2}
-
- hook_exists zone "${hook_zone}.configs/${hook_config}"
-}
-
-function hook_zone_has_configs() {
- local hook=${1}
-
- [ -d "${NETWORK_HOOKS_DIR_ZONES}/${hook}.configs" ]
-}
-
function hook_zone_exec() {
hook_exec zone $@
}
-function hook_zone_config_exec() {
- local hook_zone=${1}
- local hook_port=${2}
- shift 2
-
- hook_zone_exec "${hook_zone}.configs/${hook_port}" $@
-}
-
function hook_zone_get_all() {
- local type=${1}
-
- local hook
- for hook in $(hook_dir zone)/*; do
- hook=$(basename ${hook})
- hook_zone_exists ${hook} && echo "${hook}"
- done
+ hook_list zone
}
-function hook_zone_configs_get_all() {
- local hook=${1}
-
- if ! hook_exists zone ${hook}; then
- error "Hook '${hook}' does not exist."
- return ${EXIT_ERROR}
- fi
-
- # If the zone hook has got no configurations we exit silently
- if ! hook_zone_has_configs ${hook}; then
- return ${EXIT_OK}
- fi
+function hook_config_exists() {
+ hook_exists config $@
+}
- local h
- for h in $(hook_dir zone)/${hook}.configs/*; do
- h=$(basename ${h})
- if hook_zone_config_exists ${hook} ${h}; then
- echo "${h}"
- fi
- done
+function hook_config_exec() {
+ hook_exec config $@
+}
- return ${EXIT_OK}
+function hook_config_get_all() {
+ hook_list config
}