Skip to content

Commit

Permalink
Add a docker wrapper and explanations
Browse files Browse the repository at this point in the history
  • Loading branch information
tducret committed Jul 4, 2018
1 parent 55dde2b commit f504149
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions amazon2csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/sh

# A wrapper script for invoking a docker container
# Based on https://spin.atomicobject.com/2015/11/30/command-line-tools-docker/

DOCKER_IMAGE="thibdct/amazon2csv"

error(){
error_code=$1
echo "ERROR: $2" >&2
exit $1
}
check_cmd_in_path(){
cmd=$1
which $cmd > /dev/null 2>&1 || error 1 "$cmd not found!"
}
upgrade(){
docker pull $DOCKER_IMAGE
exit 1
}
uninstall(){
read -p "Are you sure to uninstall (y/n)? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "docker rmi $DOCKER_IMAGE"
echo "rm $0"
fi
exit 1
}

# Checks for dependencies
check_cmd_in_path docker
check_cmd_in_path docker-machine
docker-machine active > /dev/null 2>&1 || error 2 "docker-machine needs to be running."

case $1 in
--uninstall)
uninstall
;;
--upgrade)
upgrade
;;
esac

# Run our containerized command
exec docker run -it --rm $DOCKER_IMAGE "$@"

0 comments on commit f504149

Please sign in to comment.