Last active
August 29, 2015 14:19
-
-
Save sjeandeaux/b752e3d593ad6cdb2485 to your computer and use it in GitHub Desktop.
Proxy and Dockerfile
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 | |
#Verify http_proxy if presents used else ping google.com | |
docker-proxy-in() { | |
if [ -z "$http_proxy" ] && ping -c 1 google.com > /dev/null ; then | |
cat ${1:-Dockerfile} | |
else | |
sed -e "/FROM/a\\ | |
\\ | |
ENV http_proxy=\"$http_proxy\" https_proxy=\"$https_proxy\" ftp_proxy=\"$ftp_proxy\" no_proxy=\"$no_proxy\" | |
" ${1:-Dockerfile} | |
#remove information proxy | |
echo 'ENV http_proxy="" https_proxy="" ftp_proxy="" no_proxy=*' | |
fi | |
} | |
#Verify http_proxy if presents used else ping google.com | |
docker-proxy-file() { | |
if [ -z "$http_proxy" ] && ping -c 1 google.com > /dev/null ; then | |
echo ${1:-Dockerfile} | |
else | |
local file=${1:-Dockerfile}.proxy | |
sed "/FROM/a\\ | |
\\ | |
ENV http_proxy=\"$http_proxy\" https_proxy=\"$https_proxy\" ftp_proxy=\"$ftp_proxy\" no_proxy=\"$no_proxy\" | |
" ${1:-Dockerfile} > $file | |
echo 'ENV http_proxy="" https_proxy="" ftp_proxy="" no_proxy=*' >> $file | |
echo $file | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment