git-lfs/docker/gpg-agent_start.bsh
brian m. carlson 4424a6769a
Switch from which to command -v
Debian has recently deprecated the which utility and will remove it in a
future version, since POSIX specifies "command -v" for finding the
location of a path and has for some time.  In addition, which has
started complaining loudly to standard error, so it causes test and
makefile output to be hard to read.

Let's switch to the preferred invocation, command -v, in the Makefile,
build tooling, and test suite.
2021-08-23 15:30:43 +00:00

19 lines
687 B
Bash
Executable File

#!/usr/bin/env bash
#Based off of https://github.com/andyneff/gpg_agent/blob/master/start.bsh
set -eu
CUR_DIR=$(dirname ${BASH_SOURCE[0]})
IMAGE_NAME=andyneff/gpg_agent
CONTAINER_NAME=git-lfs-gpg
: ${SUDO=`if ( [ ! -w /var/run/docker.sock ] && id -nG | grep -qwv docker && [ "${DOCKER_HOST:+dh}" != "dh" ] ) && command -v sudo > /dev/null 2>&1; then echo sudo; fi`}
if [ "$(docker inspect -f {{.State.Running}} ${CONTAINER_NAME})" != "true" ]; then
OTHER_OPTIONS=("-e" "GPG_DEFAULT_CACHE=${GPG_DEFAULT_CACHE:-31536000}")
OTHER_OPTIONS+=("-e" "GPG_MAX_CACHE=${GPG_MAX_CACHE:-31536000}")
${SUDO} docker run -d -t "${OTHER_OPTIONS[@]}" --name ${CONTAINER_NAME} ${IMAGE_NAME}
fi