kiss: support a system-wide hook directory with easy use.

Hooks installed to /var/db/kiss/hooks can be accessed via their
basename. Usage is as follows.

$ ls -1 /var/db/kiss/hooks
no-docs
shell-on-exit

$ export KISS_HOOK=no-docs:shell-on-exit:/home/dylan/bin/kiss_hook

See #229
This commit is contained in:
Dylan Araps 2021-07-14 18:47:01 +03:00
parent 7fc6929516
commit 7d256b203c
No known key found for this signature in database
GPG Key ID: 13295DAC2CF13B5C
1 changed files with 12 additions and 3 deletions

15
kiss
View File

@ -120,9 +120,18 @@ run_hook() {
unset IFS
for hook do "$hook" "$_type" "$_name" "$_path" ||
die "$_name" "$_type hook failed: '$hook'"
done
for hook do case $hook in
*/*)
# Absolute path to hook.
"$hook" "$_type" "$_name" "$_path"
;;
*)
# Hook in system-wide hook directory (/var/db/kiss/hooks).
# Hooks in this directory can be used via their basename.
"$sys_db/../hooks/$hook" "$_type" "$_name" "$_path"
;;
esac || die "$_name" "$_type hook failed: '$hook'"; done
}
run_hook_pkg() {