Skip to content

Instantly share code, notes, and snippets.

@KernelFolla
Last active August 17, 2017 21:52
Show Gist options
  • Save KernelFolla/a6b5150ca6187cc3222923ce53f19084 to your computer and use it in GitHub Desktop.
Save KernelFolla/a6b5150ca6187cc3222923ce53f19084 to your computer and use it in GitHub Desktop.
run legacy capifony using docker, works on osx and linux
#!/bin/bash
IMAGE="mjanser/capifony"
CURRDIR=$(pwd)
if [ "$(uname)" == "Darwin" ]; then
# under Mac OS X platform
command -v jq >/dev/null 2>&1 || { echo >&2 "please install jq with \"brew install jq\" or \"port install jq\""; exit 1; }
docker pull $IMAGE
ENTRYPOINT=$(docker inspect $IMAGE | jq -r '.[0].ContainerConfig.Entrypoint[0]')
WORKINGDIR=$(docker inspect $IMAGE | jq -r '.[0].Config.WorkingDir')
cat > $CURRDIR/tmp-entrypoint.sh <<EOF
#!/bin/bash
eval \`ssh-agent\`
ssh-add
$ENTRYPOINT \$@
EOF
docker run --rm -it --entrypoint "/bin/bash" -v $CURRDIR:$WORKINGDIR -v ~/.ssh/known_hosts:/root/.ssh/known_hosts -v ~/.ssh/id_rsa:/root/.ssh/id_rsa $IMAGE $WORKINGDIR/tmp-entrypoint.sh $@
rm $CURRDIR/tmp-entrypoint.sh
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
# under GNU/Linux platform
docker run --rm -it -v $CURRDIR:$WORKINGDIR -v $(readlink -f $SSH_AUTH_SOCK):/root/ssh-agent -v ~/.ssh/known_hosts:/root/.ssh/known_hosts $@
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment