]>
git.proxmox.com Git - mirror_lxc.git/blob - hooks/squid-deb-proxy-client
3 # Make the cloned container aware of squid-deb-proxy settings at start.
5 # Copyright © 2014 Christopher Glass.
7 # This library is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version 2, as
9 # published by the Free Software Foundation.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with this program; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 # When starting a container, inject the squid-deb-proxy-client proxy
21 # address in the container's apt configuration.
22 # This script should be added to templates as a pre-start script, such as:
23 #lxc.hook.pre-start=/usr/share/lxc/hooks/squid-deb-proxy-client
25 discovery_script
=/usr
/share
/squid-deb-proxy-client
/apt-avahi-discover
26 proxy_file
=/etc
/apt
/apt.conf.d
/50squid-deb-proxy
27 container_proxy_file
=$LXC_ROOTFS_PATH$proxy_file
29 if [ -f $proxy_file ]; then
30 # The host has a proxy file - let's propagate the config to the guest.
31 cat $proxy_file > $container_proxy_file
35 if [ ! -f $discovery_script ]; then
36 # There is no squid-deb-proxy-client package installed. Do nothing.
40 proxy_line
=$
($discovery_script) #XXX: Could be multiline?
42 if [ -n "$proxy_line" ]; then
43 doc
="# Detected at container start from the host's squid-deb-proxy-client"
44 echo "Acquire::http::proxy \"$proxy_line\"; $doc" > $container_proxy_file
46 if [ -f $proxy_file ]; then