2012-11-09 11:04:13 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Save the HTTP if one is available.
|
|
|
|
# XXX: Obviously not suitable for downloadable images.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -o xtrace
|
|
|
|
|
2013-03-08 11:24:45 +00:00
|
|
|
if [ -d /etc/apt ] ; then
|
|
|
|
have_apt=1
|
|
|
|
fi
|
|
|
|
if [ -e /etc/yum.conf ] ; then
|
|
|
|
have_yum=1
|
|
|
|
fi
|
2013-12-09 20:13:20 +00:00
|
|
|
if [ -d /etc/zypp ] ; then
|
|
|
|
have_zypper=1
|
|
|
|
fi
|
2013-03-08 11:24:45 +00:00
|
|
|
|
2012-11-09 11:04:13 +00:00
|
|
|
if [ -n "$http_proxy" ]; then
|
2012-12-07 22:52:35 +00:00
|
|
|
if [ -d ~stack ]; then
|
2012-11-22 04:58:07 +00:00
|
|
|
echo export http_proxy=$http_proxy >> ~stack/.profile
|
2012-12-07 22:52:35 +00:00
|
|
|
fi
|
2013-03-08 11:24:45 +00:00
|
|
|
if [ -n "$have_apt" ] ; then
|
|
|
|
echo "Acquire::http::Proxy \"$http_proxy\";" > /etc/apt/apt.conf.d/61-use-http-proxy
|
|
|
|
fi
|
|
|
|
if [ -n "$have_yum" ] ; then
|
|
|
|
sed -i -e "s,\[main\],[main]\nproxy=$http_proxy," /etc/yum.conf
|
|
|
|
fi
|
2013-12-09 20:13:20 +00:00
|
|
|
if [ -n "$have_zypper" ] ; then
|
|
|
|
sed -i -e "s,^HTTP_PROXY=.*$,HTTP_PROXY=\"$http_proxy\"," /etc/sysconfig/proxy
|
|
|
|
fi
|
2012-12-07 22:52:35 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$https_proxy" ]; then
|
|
|
|
if [ -d ~stack ]; then
|
|
|
|
echo export https_proxy=$https_proxy >> ~stack/.profile
|
|
|
|
fi
|
2013-03-08 11:24:45 +00:00
|
|
|
if [ -n "$have_apt" ] ; then
|
|
|
|
echo "Acquire::https::Proxy \"$https_proxy\";" > /etc/apt/apt.conf.d/61-use-https-proxy
|
|
|
|
fi
|
2013-12-09 20:13:20 +00:00
|
|
|
if [ -n "$have_zypper" ] ; then
|
|
|
|
sed -i -e "s,^HTTPS_PROXY=.*$,HTTPS_PROXY=\"$https_proxy\"," /etc/sysconfig/proxy
|
|
|
|
fi
|
2012-12-07 22:52:35 +00:00
|
|
|
fi
|
|
|
|
|
2012-12-19 15:25:35 +00:00
|
|
|
if [ -n "$http_proxy" -o -n "$https_proxy" ]; then
|
2012-12-07 22:52:35 +00:00
|
|
|
if [ -d ~stack ]; then
|
|
|
|
echo export no_proxy=192.0.2.1 >> ~stack/.profile
|
|
|
|
fi
|
2013-12-09 20:13:20 +00:00
|
|
|
if [ -n "$have_zypper" ] ; then
|
|
|
|
sed -i -e "s,^PROXY_ENABLED=.*$,PROXY_ENABLED=\"yes\"," \
|
|
|
|
-e "s,^\(NO_PROXY=.*\)\"$,\1\, 192.0.2.1\"," /etc/sysconfig/proxy
|
|
|
|
fi
|
2012-11-09 11:04:13 +00:00
|
|
|
fi
|