forked from pigmej/docker-squid-cache
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathentrypoint.sh
43 lines (37 loc) · 1.32 KB
/
entrypoint.sh
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
38
39
40
41
42
43
#!/bin/sh
set -e
SQUID_CACHE_DIR=/var/cache/squid
SQUID_LOG_DIR=/var/log/squid
SQUID_CONF=/etc/squid/squid.conf
SSL_CERT_DIR=/etc/squid/ssl_cert
chown -R squid:squid ${SQUID_CACHE_DIR}
chown -R squid:squid ${SQUID_LOG_DIR}
chown -R squid:squid ${SSL_CERT_DIR}
chmod 755 ${SSL_CERT_DIR}
echo "Checking certificate..."
if [[ ! -f ${SSL_CERT_DIR}/squid-proxy.pem ]]
then
echo "No certificate file found. Initializing new certificate..."
openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout ${SSL_CERT_DIR}/squid-proxy.pem -out ${SSL_CERT_DIR}/squid-proxy.pem -extensions v3_ca -subj "/C=US/ST=WhoCaresAboutIt/L=NotImportantAtAll/O=NotImportant"
else
echo "Found existing certificate at ${SSL_CERT_DIR}/squid-proxy.pem"
fi
echo "Checking ssl_db..."
if [[ ! -f "/var/lib/ssl_db/index.txt" ]]
then
echo "No index file found in ssl_db. Initializing new ssl_db directory..."
/usr/lib/squid/ssl_crtd -c -s /var/lib/ssl_db
chown squid:squid -R /var/lib/ssl_db
else
echo "Found existing index file in ssl_db at '/var/lib/ssl_db'"
fi
echo "Checking cache..."
if [[ ! -d ${SQUID_CACHE_DIR}/00 ]]
then
echo "No existing cache found. Initializing new cache..."
squid -N -f ${SQUID_CONF} -z
else
echo "Found existing cache at ${SQUID_CACHE_DIR}"
fi
echo "Starting Squid..."
exec squid -f ${SQUID_CONF} -NYCd 1