1
0
mirror of https://github.com/falk-werner/webfuse synced 2024-10-27 20:34:10 +00:00
falk-werner_webfuse/build/get_container_id.sh
nosamad 0ac03b6150 feat(webfuse): eclipse cdt project (#17)
adds convenience run and discovery targets (for first build target)
allows usage of host container (volume mount/ dind)
fixes portable workspace configuration
adds makefile targets to CDT configuration
fixes localization

* adds eclipse-cdt project and necessary discovery for toolchain settings

* extends targets and fixes discovery

* renames CDT Eclipse project

* enables portable workspace docker-build on build server
2019-03-28 07:43:21 +01:00

40 lines
730 B
Bash
Executable File

#!/bin/sh
set -e
container_id() {
if [ "$#" -le 0 ]; then
# shellcheck disable=SC2119
container_id_by_cgroup
else
"$DOCKER" inspect --format='{{.Id}}' "$@"
fi
}
# shellcheck disable=SC2120
container_id_by_cgroup() {
impl_container_id_by_cgroup "$@" || return "$?"
}
impl_container_id_by_cgroup() {
file="${1:-/proc/self/cgroup}"
while IFS= read -r cmd; do
id="$(echo "$cmd" | sed -n -e 's/[^:]*:[^:]*:.*\/\([0-9a-fA-F]\+\)$/\1/p')"
if container_id "$id" >/dev/null 2>&1; then
echo "$id"
return 0
fi
done < "$file"
return 1
}
DOCKER="${DOCKER:-docker}"
if [ -z "${CONTAINER+x}" ] && [ -n "$DOCKER" ]; then
CONTAINER="$(container_id "$@")" || true
fi
echo "$CONTAINER"