diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-02-23 13:44:29 -0500 |
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-02-23 13:44:29 -0500 |
| commit | a63ed0801a341499e20ff6e3ecc8b8b685b15c44 (patch) | |
| tree | b4440eafc83c919e5c6c0092008904eecf7694bc | |
| parent | afc5e98c29ed1d61d2c35cb6911c7b87cfce32f2 (diff) | |
| download | bashflows-a63ed0801a341499e20ff6e3ecc8b8b685b15c44.tar.gz | |
Initial commit
| -rw-r--r-- | tasks/common/functions.sh | 15 | ||||
| -rw-r--r-- | tasks/hst/rt/env.sh | 1 | ||||
| -rw-r--r-- | tasks/hst/rt/run.sh | 12 | ||||
| -rw-r--r-- | tasks/task.sh | 44 |
4 files changed, 72 insertions, 0 deletions
diff --git a/tasks/common/functions.sh b/tasks/common/functions.sh new file mode 100644 index 0000000..8ae2108 --- /dev/null +++ b/tasks/common/functions.sh @@ -0,0 +1,15 @@ +get_common_dir() { + echo $(realpath $(dirname ${BASH_SOURCE[0]})/common) +} + +pre() { + echo "pre not implemented" +} + +post() { + echo "post not implemented" +} + +run() { + echo "run not implemented" +} diff --git a/tasks/hst/rt/env.sh b/tasks/hst/rt/env.sh new file mode 100644 index 0000000..6c01a23 --- /dev/null +++ b/tasks/hst/rt/env.sh @@ -0,0 +1 @@ +export SOURCED_ENV_FILE=1 diff --git a/tasks/hst/rt/run.sh b/tasks/hst/rt/run.sh new file mode 100644 index 0000000..3be6b66 --- /dev/null +++ b/tasks/hst/rt/run.sh @@ -0,0 +1,12 @@ +pre() { + echo "I do things before running." +} + +run() { + echo "I run things." + echo SOURCED_ENV_FILE=${SOURCED_ENV_FILE} +} + +post() { + echo "I do things after running." +} 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!" |
