aboutsummaryrefslogtreecommitdiff
path: root/tasks/task.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tasks/task.sh')
-rw-r--r--tasks/task.sh44
1 files changed, 44 insertions, 0 deletions
diff --git a/tasks/task.sh b/tasks/task.sh
new file mode 100644
index 0000000..5a0ff09
--- /dev/null
+++ b/tasks/task.sh
@@ -0,0 +1,44 @@
+common_dir=$(realpath $(dirname ${BASH_SOURCE[0]})/common)
+
+task=$1
+if [ -z "$task" ]; then
+ echo "task directory required" >&2
+ exit 1
+fi
+
+if ! [ -d "$task" ]; then
+ echo "task directory does not exist: ${task}" >&2
+ exit 1
+fi
+
+if [ -f "$task"/env.sh ]; then
+ source "$task"/env.sh
+fi
+
+if ! [ -f "$task"/run.sh ]; then
+ echo "missing script: ${task}/run.sh"
+ exit 1
+fi
+
+source ${common_dir}/functions.sh
+source "$task"/run.sh
+
+task_func=(
+ pre
+ run
+ post
+)
+
+for x in "${task_func[@]}"; do
+ step="${task}::${x}()"
+ echo
+ echo "[$step] Executing"
+ ${x}
+ retval=$?
+ if (( $retval )); then
+ echo "[$step] Failed (returned $retval)" >&2
+ exit 1
+ fi
+ echo
+done
+echo "Done!"