mirror of
https://github.com/falk-werner/webfuse
synced 2024-10-27 20:34:10 +00:00
adds checksum for fetch dependencies discovers necessary commands fixes error when script get_container_id not found
42 lines
949 B
Bash
42 lines
949 B
Bash
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
DOCKER="${DOCKER:-%DOCKER%}"
|
|
IMAGE="${IMAGE:-%IMAGE%}"
|
|
NETWORK="${NETWORK:-host}"
|
|
PROJECT_ROOT="${PROJECT_ROOT:-%PROJECT_ROOT%}"
|
|
CONTAINER_ID_CMD="$PROJECT_ROOT/build/get_container_id.sh"
|
|
|
|
if command -v "$CONTAINER_ID_CMD" 2>&1 1>/dev/null; then
|
|
HOST_CONTAINER="${HOST_CONTAINER:-"$("$CONTAINER_ID_CMD")"}" || true
|
|
else
|
|
echo "warning:$0: failed to discover host environment" 1>&2
|
|
fi
|
|
|
|
# shellcheck disable=SC2162
|
|
read -a ADDITIONAL_RUNFLAGS <<< "$RUNFLAGS"
|
|
|
|
RUNFLAGS=()
|
|
|
|
# shellcheck disable=SC2191
|
|
RUNFLAGS+=( %RUNFLAGS% )
|
|
|
|
if [[ -n "$HOST_CONTAINER" ]]; then
|
|
RUNFLAGS+=( --volumes-from "$HOST_CONTAINER" )
|
|
fi
|
|
|
|
RUNFLAGS+=( --network "$NETWORK" )
|
|
|
|
if [[ -n "$CONTAINER_CGROUP_PARENT" ]]; then
|
|
RUNFLAGS+=( --cgroup-parent "$CONTAINER_CGROUP_PARENT" )
|
|
fi
|
|
|
|
RUNFLAGS+=( --workdir "$PWD" )
|
|
|
|
RUNCMD=( %RUNCMD% )
|
|
|
|
set -- "${RUNFLAGS[@]}" "${ADDITIONAL_RUNFLAGS[@]}" "$IMAGE" "${RUNCMD[@]}" "$@"
|
|
|
|
exec "$DOCKER" run "$@"
|