Created
March 6, 2016 05:28
-
-
Save fffonion/baa7a1f7707c626dac24 to your computer and use it in GitHub Desktop.
docker_driver.sh
This file contains hidden or 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 | |
repo=[SITE]/[USERNAME]/[REPO] | |
# example: fffonion/233 | |
# index.hahah.io/fffonion/233 | |
# upload a file | |
# ./docker_driver.sh YOUR_FILE | |
# copy the md5 | |
# grab a file | |
# ./docker_driver.sh MD5 | |
# the file will be downloaded into current directory | |
if [ -e "$1" ] ; then | |
md5=`md5sum $1|cut -d " " -f 1` | |
echo MD5 is $md5 | |
tar -c $1 | docker import - $repo:$md5 > /dev/null | |
docker push $repo:$md5 | |
docker rmi $repo:$md5 > /dev/null | |
else | |
docker pull $repo:$1 | |
pushd /tmp | |
docker save $repo:$1|tar -x > /dev/null | |
docker rmi $repo:$1 > /dev/null | |
ls|grep -oP ".{64}\.json"|xargs rm | |
d=`ls|grep -oP ".{64}\$"` | |
popd | |
tar xf /tmp/$d/layer.tar | |
rm -rf /tmp/$d | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment