]>
Commit | Line | Data |
---|---|---|
4213a747 CG |
1 | #!/bin/sh |
2 | # | |
3 | # Make the cloned container aware of squid-deb-proxy settings at start. | |
4 | # | |
5 | # Copyright © 2014 Christopher Glass. | |
6 | # | |
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. | |
10 | # | |
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. | |
15 | # | |
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. | |
19 | ||
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 | |
24 | ||
25 | discovery_script=/usr/share/squid-deb-proxy-client/apt-avahi-discover | |
26 | proxy_file=/etc/apt/apt.conf.d/50squid-deb-proxy | |
959dd8f2 | 27 | container_proxy_file=$LXC_ROOTFS_PATH$proxy_file |
4213a747 CG |
28 | |
29 | if [ -f $proxy_file ]; then | |
30 | # The host has a proxy file - let's propagate the config to the guest. | |
4213a747 CG |
31 | cat $proxy_file > $container_proxy_file |
32 | exit 0 | |
33 | fi | |
34 | ||
35 | if [ ! -f $discovery_script ]; then | |
36 | # There is no squid-deb-proxy-client package installed. Do nothing. | |
37 | exit 0 | |
38 | fi | |
39 | ||
40 | proxy_line=$($discovery_script) #XXX: Could be multiline? | |
41 | ||
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 | |
45 | else | |
46 | if [ -f $proxy_file ]; then | |
47 | rm $proxy_file | |
48 | fi | |
49 | fi | |
50 | exit 0 |