# #
###############################################################################
-function hook_dir() {
+hook_dir() {
local type=${1}
if [ -n "${type}" ]; then
}
NETWORK_HOOKS_DIR_ZONES="$(hook_dir zone)"
-function hook_exists() {
+hook_exists() {
local type=${1}
local hook=${2}
[ ! -d "${hook}" ] && [ -x "${hook}" ]
}
-function hook_exec() {
+hook_exec() {
local type="${1}"
assert isset type
${EXIT_COMMAND_NOT_FOUND}|${EXIT_NOT_SUPPORTED})
log ERROR "Hook '${hook}' does not implement the method '${cmd}':"
log ERROR " arguments: $@"
- exit ${EXIT_COMMAND_NOT_FOUND}
+ return ${EXIT_COMMAND_NOT_FOUND}
;;
${EXIT_ERROR_ASSERT})
log ERROR "Hook exited with an assertion error."
- exit ${EXIT_ERROR_ASSERT}
+ return ${EXIT_ERROR_ASSERT}
;;
esac
return ${ret}
}
-function hook_list() {
+hook_list() {
local type="${1}"
local dir="$(hook_dir "${type}")"
assert isset dir
local hook
- for hook in ${dir}/*; do
- hook="$(basename "${hook}")"
-
+ for hook in $(list_directory "${dir}"); do
if hook_exists "${type}" "${hook}"; then
echo "${hook}"
fi
}
# The default help function.
-function hook_help() {
+hook_help() {
# If no man page has been configured, we print an error message.
if [ -z "${HOOK_MANPAGE}" ]; then
error "There is no help available for hook '${HOOK}'. Exiting."
exit $?
}
-function config_get_hook() {
+# Dummy functions being overlayed by hooks
+hook_check_settings() {
+ :
+}
+
+hook_check_config_settings() {
+ :
+}
+
+hook_check_port_settings() {
+ :
+}
+
+# Sets all settings in HOOK_SETTINGS to their DEFAULT_* values
+hook_set_defaults() {
+ local setting
+ for setting in ${HOOK_SETTINGS[*]}; do
+ local default="DEFAULT_${setting}"
+
+ # Sets the default or empty
+ assign "${setting}" "${!default}"
+ done
+}
+
+config_get_hook() {
local config=${1}
assert isset config
)
}
-function hook_zone_exists() {
- hook_exists zone $@
+hook_zone_exists() {
+ hook_exists zone "$@"
}
-function hook_zone_exec() {
- hook_exec zone $@
+hook_zone_exec() {
+ hook_exec zone "$@"
}
-function hook_zone_get_all() {
+hook_zone_get_all() {
hook_list zone
}
-function hook_config_exists() {
- hook_exists config $@
+hook_config_exists() {
+ hook_exists config "$@"
}
-function hook_config_exec() {
- hook_exec config $@
+hook_config_exec() {
+ hook_exec config "$@"
}
-function hook_config_get_all() {
+hook_config_get_all() {
hook_list config
}
-function hook_valid_command() {
+hook_valid_command() {
local type="${1}"
local cmd="${2}"
return ${EXIT_FALSE}
}
-function hook_valid_command_config() {
+hook_valid_command_config() {
local cmd="${1}"
case "${cmd}" in
- create|remove|edit|up|down|status)
+ new|destroy|edit|up|down|status|hid)
return ${EXIT_TRUE}
;;
esac
return ${EXIT_FALSE}
}
-function hook_valid_command_port() {
+hook_valid_command_port() {
local cmd="${1}"
case "${cmd}" in
;;
# Status
- status|info)
+ status|children)
return ${EXIT_TRUE}
;;
esac
return ${EXIT_FALSE}
}
-function hook_valid_command_zone() {
+hook_valid_command_zone() {
local cmd="${1}"
case "${cmd}" in
return ${EXIT_TRUE}
;;
- config_create|config_edit|config_remove|config_show)
+ config_new|config_destroy|config_edit|config_show)
return ${EXIT_TRUE}
;;
;;
# Ports
- port_add|port_edit|port_create|port_remove|port_show|port_status|port_up|port_down)
+ port_attach|port_detach|port_edit|port_create|port_remove|port_status|port_up|port_down)
return ${EXIT_TRUE}
;;