Created
September 26, 2013 18:56
-
-
Save fsouza/6718898 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -u | |
docker="docker -H 127.0.0.1:4243" | |
if [ $# -lt 2 ] | |
then | |
echo >&2 "ERROR: wrong number of parameters." | |
echo >&2 | |
echo >&2 "Usage:" | |
echo >&2 " $0 <image> <path_on_container::url> [path_on_conainer:url] ..." | |
exit 1 | |
fi | |
PREFIX=registry.cloud.tsuru.io/tsuru/ | |
suffix=$1 | |
image=$PREFIX$suffix | |
command="" | |
for param in "$@" | |
do | |
if [ "x${param}x" != "x${suffix}x" ] | |
then | |
parts=(${param//::/ }) | |
if [ ${#parts[@]} != 2 ] | |
then | |
echo >&2 "ERROR: Invalid path to URL mapping." | |
echo >&2 | |
echo >&2 " The valid format is <path_on_container>::<url>" | |
exit 1 | |
fi | |
wget_command="wget ${parts[1]} -O ${parts[0]}" | |
if [ "x${command}x" = "xx" ] | |
then | |
command=$wget_command | |
else | |
command="$command && $wget_command" | |
fi | |
fi | |
done | |
id=`$docker run -d $image /bin/bash -c "$command"` | |
status=`$docker wait $id` | |
if [ "$status" = "0" ] | |
then | |
$docker commit $id $image | |
fi | |
$docker rm $id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment