This repository has been archived by the owner on Mar 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proxy non-native task execution via script
- Resolves #235
- Loading branch information
Showing
5 changed files
with
181 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -o pipefail | ||
|
||
# environment variables used | ||
# SHIPYARD_USER_PROLOGUE_CMD: pre-exec user cmd | ||
# SHIPYARD_USER_EPILOGUE_CMD: post-exec user cmd | ||
# SHIPYARD_ENV_EXCLUDE: environment vars to exclude | ||
# SHIPYARD_ENV_FILE: env file | ||
# SHIPYARD_RUNTIME: docker or singularity | ||
# SHIPYARD_RUNTIME_CMD: run or exec | ||
# SHIPYARD_RUNTIME_CMD_OPTS: options | ||
# SHIPYARD_CONTAINER_IMAGE_NAME: container name | ||
|
||
## PRE-EXEC | ||
if [ -n "$SHIPYARD_USER_PROLOGUE_CMD" ]; then | ||
eval "$SHIPYARD_USER_PROLOGUE_CMD" | ||
fi | ||
|
||
## TASK EXEC | ||
# dump env for envfile | ||
if [ -n "$SHIPYARD_ENV_EXCLUDE" ]; then | ||
env | grep -vE "$SHIPYARD_ENV_EXCLUDE" > "$SHIPYARD_ENV_FILE" | ||
else | ||
env > "$SHIPYARD_ENV_FILE" | ||
fi | ||
|
||
cat "$SHIPYARD_ENV_FILE" | ||
|
||
SHIPYARD_RUNTIME_CMD_OPTS=$(eval echo "${SHIPYARD_RUNTIME_CMD_OPTS}") | ||
|
||
if [ -n "$SHIPYARD_RUNTIME" ]; then | ||
# shellcheck disable=SC2086 | ||
"$SHIPYARD_RUNTIME" "$SHIPYARD_RUNTIME_CMD" $SHIPYARD_RUNTIME_CMD_OPTS \ | ||
"$SHIPYARD_CONTAINER_IMAGE_NAME" "$@" | ||
else | ||
"$@" | ||
fi | ||
|
||
## POST EXEC | ||
if [ -n "$SHIPYARD_USER_EPILOGUE_CMD" ]; then | ||
eval "$SHIPYARD_USER_EPILOGUE_CMD" | ||
fi |