aboutsummaryrefslogtreecommitdiff
path: root/lib/hooks.sh
blob: 408f0846b6e2f9a5b5fbda91780ff5e39e4d5851 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Functions for hooks

# 1: Name of hook
call_hook() {
	local HOOK="$1"
	shift

	if [ !  -x "hooks/$HOOK.hook" ]; then
		debug "$HOOK.hook was not found. Skipping."
		return
	fi

	debug "Running hook $HOOK"

	hooks/$HOOK.hook "$@" 2>&1 | (while read line; do echo [hook: $HOOK] $line; done)
	RET=${PIPESTATUS[0]}

	if [ $RET -ne 0 ]; then
		warning "Hook $HOOK exitet with code $RET"
	fi
}