4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass# Make the cloned container aware of squid-deb-proxy settings at start.
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass# Copyright © 2014 Christopher Glass.
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass# This library is free software; you can redistribute it and/or modify
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass# it under the terms of the GNU General Public License version 2, as
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass# published by the Free Software Foundation.
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass# This program is distributed in the hope that it will be useful,
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass# but WITHOUT ANY WARRANTY; without even the implied warranty of
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass# GNU General Public License for more details.
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass# You should have received a copy of the GNU General Public License along
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass# with this program; if not, write to the Free Software Foundation, Inc.,
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass# When starting a container, inject the squid-deb-proxy-client proxy
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass# address in the container's apt configuration.
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass# This script should be added to templates as a pre-start script, such as:
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass#lxc.hook.pre-start=/usr/share/lxc/hooks/squid-deb-proxy-client
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glassdiscovery_script=/usr/share/squid-deb-proxy-client/apt-avahi-discover
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glassif [ -f $proxy_file ]; then
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass # The host has a proxy file - let's propagate the config to the guest.
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glassif [ ! -f $discovery_script ]; then
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass # There is no squid-deb-proxy-client package installed. Do nothing.
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glassproxy_line=$($discovery_script) #XXX: Could be multiline?
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glassif [ -n "$proxy_line" ]; then
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass doc="# Detected at container start from the host's squid-deb-proxy-client"
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass echo "Acquire::http::proxy \"$proxy_line\"; $doc" > $container_proxy_file
4213a747e8f2f953114be798bab0e2bf11da4563Chris Glass if [ -f $proxy_file ]; then