summaryrefslogtreecommitdiffstats
path: root/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
diff options
context:
space:
mode:
authorSimon Rettberg2019-05-17 12:30:24 +0200
committerSimon Rettberg2019-05-17 12:30:24 +0200
commite384d068e1f101087b85e97c35ef1d434cc7790a (patch)
treebc8130eed93bc8eee730fa3431f7fc8e70ddea25 /core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
parent[screen-standby] Remove forgotten interfering module (diff)
downloadmltk-e384d068e1f101087b85e97c35ef1d434cc7790a.tar.gz
mltk-e384d068e1f101087b85e97c35ef1d434cc7790a.tar.xz
mltk-e384d068e1f101087b85e97c35ef1d434cc7790a.zip
[run-virt] Add hook system, remove legacy code
Diffstat (limited to 'core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc')
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc28
1 files changed, 28 insertions, 0 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
index 932c4aad..7b4554ea 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
@@ -220,6 +220,34 @@ translate() {
fi
}
+##
+# run_hooks type args...
+# eg run_hooks "download" "$CONFDIR"
+# returns 100 if no hooks exist
+run_hooks() {
+ local dir file retval r
+ declare -a files
+ dir="$BASEDIR/hooks/${1}.d"
+ [ -d "$dir" ] || return 100
+ shift
+ files=( "${dir}"/* )
+ retval=100
+ for file in "${files[@]}"; do
+ [ -e "${file}" ] || continue
+ r=100
+ if [ "${file##*.}" = "sh" ] && [ -x "$file" ]; then
+ export TMPDIR IMGUUID USER
+ "$file" "$@"
+ r="$?"
+ elif [ "${file##.*}" = "inc" ]; then
+ . "$file"
+ r="$?"
+ fi
+ [ "$r" -lt "$retval" ] && retval="$r"
+ done
+ return "$retval"
+}
+
################# SOURCING FUNCTIONS #################
# Wrapped 'source' that first checks for existence and
# syntax before actually sourcing the given file.