File: squid-deb-proxy-client

package info (click to toggle)
lxc 1%3A6.0.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,808 kB
  • sloc: ansic: 68,840; sh: 4,266; python: 135; makefile: 59
file content (37 lines) | stat: -rwxr-xr-x 1,162 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
#
# SPDX-License-Identifier: GPL-2.0-only
#
# Make the cloned container aware of squid-deb-proxy settings at start.

# When starting a container, inject the squid-deb-proxy-client proxy
# address in the container's apt configuration.
# This script should be added to templates as a pre-start script, such as:
#lxc.hook.pre-start=/usr/share/lxc/hooks/squid-deb-proxy-client

discovery_script=/usr/share/squid-deb-proxy-client/apt-avahi-discover
proxy_file=/etc/apt/apt.conf.d/50squid-deb-proxy
container_proxy_file=$LXC_ROOTFS_PATH$proxy_file

if [ -f $proxy_file ]; then
    # The host has a proxy file - let's propagate the config to the guest.
    cat $proxy_file > $container_proxy_file
    exit 0
fi

if [ ! -f $discovery_script ]; then
    # There is no squid-deb-proxy-client package installed. Do nothing.
    exit 0
fi

proxy_line=$($discovery_script)  #XXX: Could be multiline?

if [ -n "$proxy_line" ]; then
    doc="# Detected at container start from the host's squid-deb-proxy-client"
    echo "Acquire::http::proxy \"$proxy_line\"; $doc" > $container_proxy_file
else
    if [ -f $proxy_file ]; then
        rm $proxy_file
    fi
fi
exit 0