Skip to content

Instantly share code, notes, and snippets.

@Grynn
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Grynn/638b998df8c6af1b6b66 to your computer and use it in GitHub Desktop.
Save Grynn/638b998df8c6af1b6b66 to your computer and use it in GitHub Desktop.
Run grynn/speedtest (via Docker) on a random port: curl -sS https://gist.githubusercontent.com/Grynn/638b998df8c6af1b6b66/raw/run-speedtest.sh | bash
#!/bin/bash
set -e
DEBUG=1
while getopts p:h:v? flag; do
case $flag in
p)
opt_p=$OPTARG
;;
h)
opt_h=$OPTARG
;;
v)
opt_v=1
;;
\?)
echo "usage: $(basename $0) [-p 80] [-h hostname]"
exit 1
;;
esac
done
if [ -z $opt_p ]; then opt_p="-P"; else opt_p="-p $opt_p:80"; fi
if [ -z $opt_h ]; then opt_h="-e HOST=$(uname -n)"; else opt_h="-e HOST=$opt_h"; fi
shift $(( OPTIND - 1 ));
[ -z $DEBUG -o ! -z "$opt_v" ] || (echo "DEBUG: opt_p: $opt_p";
echo "DEBUG: opt_h: $opt_h";
echo "DEBUG: opt_*: $*")
docker run $opt_p $opt_h -d --name speedtest grynn/speedtest
docker inspect -f '{{ .HostConfig.PortBindings }}' speedtest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment