cfg/bin/dtool
Knut Ahlers d81bd6e56d
Add dtool
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2018-10-22 22:19:40 +02:00

26 lines
537 B
Bash
Executable file

#!/bin/bash
set -euo pipefail
source ${HOME}/bin/script_framework.sh
[ $# -lt 1 ] && fail "At least the tool must be specified"
TOOL=$1
shift
toolimage="dtool.local/${TOOL}"
docker images | grep -q "^${toolimage}" || {
step "Building tool image for \"${TOOL}\""
toolpath="${HOME}/.config/dtool/${TOOL}"
docker build -q \
-t "${toolimage}" \
--build-arg UID=$(id -u) \
"${toolpath}"
}
step "Executing \"${toolimage} $@\"..."
exec docker run --rm -ti \
-u $(id -u) \
-v "$(pwd):$(pwd)" -w "$(pwd)" \
"${toolimage}" "$@"