]> git.ipfire.org Git - people/arne_f/network.git/blobdiff - functions.hook
network: Again very much changes that are hard to break down.
[people/arne_f/network.git] / functions.hook
index 57b5389eeea0ba6c7041027550598d705e240633..5b93bfe0151aed9840ca251f9fc935e5dce7566e 100644 (file)
 function hook_dir() {
        local type=${1}
 
-       echo "${HOOKS_DIR}/${type}s"
+       if [ -n "${type}" ]; then
+               type="/${type}s"
+       fi
+
+       echo "${HOOKS_DIR}${type}"
 }
 
 function hook_exists() {
        local type=${1}
        local hook=${2}
 
+       assert isset type
+       assert isset hook
+
        local hook_dir=$(hook_dir ${type})
 
        [ -d "${hook_dir}/${hook}" ] && return ${EXIT_ERROR}
@@ -41,6 +48,9 @@ function hook_exec() {
        local hook=${2}
        shift 2
 
+       assert isset type
+       assert isset hook
+
        if ! hook_exists ${type} ${hook}; then
                error "Hook '${hook}' does not exist."
                return ${EXIT_ERROR}
@@ -52,6 +62,8 @@ function hook_exec() {
 function config_get_hook() {
        local config=${1}
 
+       assert isset config
+
        (
                . ${config}
                echo "${HOOK}"