From b0bae987464d5aae02505800dfe8cebc7adccb22 Mon Sep 17 00:00:00 2001 From: Alex Tomlins Date: Thu, 31 Mar 2011 09:39:39 +0100 Subject: [PATCH] Use configured apt_proxy in guests. --- etc/xen-tools.conf | 3 ++- hooks/dapper/20-setup-apt | 9 ++++++--- hooks/debian/20-setup-apt | 9 ++++++--- hooks/edgy/20-setup-apt | 9 ++++++--- hooks/intrepid/20-setup-apt | 9 ++++++--- hooks/karmic/20-setup-apt | 9 ++++++--- 6 files changed, 32 insertions(+), 16 deletions(-) diff --git a/etc/xen-tools.conf b/etc/xen-tools.conf index b241316..a3a1e25 100644 --- a/etc/xen-tools.conf +++ b/etc/xen-tools.conf @@ -278,7 +278,8 @@ mirror = `xt-guess-suite-and-mirror --mirror` # mirror_maverick = http://archive.ubuntu.com/ubuntu # mirror_natty = http://archive.ubuntu.com/ubuntu -# If this is defined it will be used by debootstrap +# If this is defined it will be used by debootstrap, and configured as the +# proxy for the guest # # apt_proxy = diff --git a/hooks/dapper/20-setup-apt b/hooks/dapper/20-setup-apt index 4fdd008..f255dfb 100755 --- a/hooks/dapper/20-setup-apt +++ b/hooks/dapper/20-setup-apt @@ -33,9 +33,12 @@ logMessage Script $0 starting # replicate that setup in our new guest via apt-config dump and save # the setting to the proxy guess file. # -logMessage The use of a proxy detected. -apt-config dump | grep -i Acquire::HTTP::Proxy \ - > ${prefix}/etc/apt/apt.conf.d/proxy-guess +if [ ${apt_proxy} ]; then + echo "Acquire::http::Proxy \"${apt_proxy}\";" > ${prefix}/etc/apt/apt.conf.d/01proxy +else + logMessage The use of a proxy detected. + apt-config dump | grep -i Acquire::HTTP::Proxy > ${prefix}/etc/apt/apt.conf.d/01proxy +fi # diff --git a/hooks/debian/20-setup-apt b/hooks/debian/20-setup-apt index 446cd67..b325602 100755 --- a/hooks/debian/20-setup-apt +++ b/hooks/debian/20-setup-apt @@ -32,9 +32,12 @@ logMessage Script $0 starting # replicate that setup in our new guest via apt-config dump and save # the setting to the proxy guess file. # -logMessage The use of a proxy detected. -apt-config dump | grep -i Acquire::HTTP::Proxy \ - > ${prefix}/etc/apt/apt.conf.d/proxy-guess +if [ ${apt_proxy} ]; then + echo "Acquire::http::Proxy \"${apt_proxy}\";" > ${prefix}/etc/apt/apt.conf.d/01proxy +else + logMessage The use of a proxy detected. + apt-config dump | grep -i Acquire::HTTP::Proxy > ${prefix}/etc/apt/apt.conf.d/01proxy +fi # diff --git a/hooks/edgy/20-setup-apt b/hooks/edgy/20-setup-apt index 4463ed5..5833c47 100755 --- a/hooks/edgy/20-setup-apt +++ b/hooks/edgy/20-setup-apt @@ -33,9 +33,12 @@ logMessage Script $0 starting # replicate that setup in our new guest via apt-config dump and save # the setting to the proxy guess file. # -logMessage The use of a proxy detected. -apt-config dump | grep -i Acquire::HTTP::Proxy \ - > ${prefix}/etc/apt/apt.conf.d/proxy-guess +if [ ${apt_proxy} ]; then + echo "Acquire::http::Proxy \"${apt_proxy}\";" > ${prefix}/etc/apt/apt.conf.d/01proxy +else + logMessage The use of a proxy detected. + apt-config dump | grep -i Acquire::HTTP::Proxy > ${prefix}/etc/apt/apt.conf.d/01proxy +fi # diff --git a/hooks/intrepid/20-setup-apt b/hooks/intrepid/20-setup-apt index 4463ed5..5833c47 100755 --- a/hooks/intrepid/20-setup-apt +++ b/hooks/intrepid/20-setup-apt @@ -33,9 +33,12 @@ logMessage Script $0 starting # replicate that setup in our new guest via apt-config dump and save # the setting to the proxy guess file. # -logMessage The use of a proxy detected. -apt-config dump | grep -i Acquire::HTTP::Proxy \ - > ${prefix}/etc/apt/apt.conf.d/proxy-guess +if [ ${apt_proxy} ]; then + echo "Acquire::http::Proxy \"${apt_proxy}\";" > ${prefix}/etc/apt/apt.conf.d/01proxy +else + logMessage The use of a proxy detected. + apt-config dump | grep -i Acquire::HTTP::Proxy > ${prefix}/etc/apt/apt.conf.d/01proxy +fi # diff --git a/hooks/karmic/20-setup-apt b/hooks/karmic/20-setup-apt index 4463ed5..5833c47 100755 --- a/hooks/karmic/20-setup-apt +++ b/hooks/karmic/20-setup-apt @@ -33,9 +33,12 @@ logMessage Script $0 starting # replicate that setup in our new guest via apt-config dump and save # the setting to the proxy guess file. # -logMessage The use of a proxy detected. -apt-config dump | grep -i Acquire::HTTP::Proxy \ - > ${prefix}/etc/apt/apt.conf.d/proxy-guess +if [ ${apt_proxy} ]; then + echo "Acquire::http::Proxy \"${apt_proxy}\";" > ${prefix}/etc/apt/apt.conf.d/01proxy +else + logMessage The use of a proxy detected. + apt-config dump | grep -i Acquire::HTTP::Proxy > ${prefix}/etc/apt/apt.conf.d/01proxy +fi #