From a33398b6d5bf47c9ded986508a549d9040060d72 Mon Sep 17 00:00:00 2001 From: Will Rouesnel Date: Fri, 1 Apr 2016 09:42:17 +1100 Subject: [PATCH] Add EXTRA_CONFIG and CONFIG_DISABLE options. --- README.md | 9 ++++++++- docker-squid/squid.bsh | 32 ++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ac8827e..d5e59c9 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,14 @@ variables: Cache peers for the squid instance may be specified with multiple CACHE_PEER environment variables. The suffix of each is used to determine ordering by the unix `sort` function. - + * `EXTRA_CONFIGx` + Extra non-specific configuration lines to be appended after the main body of + the configuration file. This is a good place for custom ACL parameters. + * `CONFIG_DISABLE` + Default `no` + If set to `yes` then squid configuration templating is disabled entirely, allowing + bind mounting the configuration file in manually instead. The certificate and SSL + setup still runs normally. # Example Usage The following command line will get you up and running quickly. It presumes diff --git a/docker-squid/squid.bsh b/docker-squid/squid.bsh index e89e5a3..564ca37 100755 --- a/docker-squid/squid.bsh +++ b/docker-squid/squid.bsh @@ -43,15 +43,31 @@ chown -R proxy: /var/lib/ssl_db #ssl_db # Set the configuration -p2 -t /squid.conf.p2 > /etc/squid4/squid.conf +if [ "$CONFIG_DISABLE" != "yes" ]; then + p2 -t /squid.conf.p2 > /etc/squid4/squid.conf -# Parse the cache peer lines from the environment and add them to the -# configuration -echo '# CACHE PEERS FROM DOCKER' >> /etc/squid4/squid.conf -env | grep 'CACHE_PEER' | sort | while read cacheline; do - echo "# $cacheline " >> /etc/squid4/squid.conf - echo "cache_peer ${!cacheline}" >> /etc/squid4/squid.conf -done + # Parse the cache peer lines from the environment and add them to the + # configuration + echo '# CACHE PEERS FROM DOCKER' >> /etc/squid4/squid.conf + env | grep 'CACHE_PEER' | sort | while read cacheline; do + echo "# $cacheline " >> /etc/squid4/squid.conf + echo "cache_peer ${!cacheline}" >> /etc/squid4/squid.conf + done + + # Parse the extra config lines and append them to the configuration + echo '# EXTRA CONFIG FROM DOCKER' >> /etc/squid4/squid.conf + env | grep 'EXTRA_CONFIG' | sort | while read extraline; do + echo "# $extraline " >> /etc/squid4/squid.conf + echo "${!extraline}" >> /etc/squid4/squid.conf + done +else + echo "CONFIGURATION TEMPLATING IS DISABLED." +fi + +if [ ! -e /etc/squid4/squid.conf ]; then + echo "ERROR: /etc/squid4/squid.conf does not exist. Squid will not work." + exit 1 +fi squid -z -N squid -N