-
Notifications
You must be signed in to change notification settings - Fork 8
/
startSquidGuard
58 lines (49 loc) · 2.17 KB
/
startSquidGuard
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
set -e
if [ "${UPDATE_BLACKLIST_URL}" != "" ]; then
sudo wget -O backlist.tar.gz ${UPDATE_BLACKLIST_URL} \
&& tar -xzf backlist.tar.gz -C /var/lib/squidguard/db \
&& rm backlist.tar.gz \
&& chown proxy:proxy /var/lib/squidguard/db -R
fi
if [ ! -f /etc/squidguard/squidGuard.conf ]; then
# if this file doesn't exist -> it is the first time
if [ "${SQUID_UID}" != "" ]; then
# workaround for mac os mapping problem:
sudo usermod -u ${SQUID_UID} proxy
fi
# chown is required especially because directories can be mapped
chown -R proxy:proxy /var/lib/squidguard/db /sample-config-simple /sample-config-blacklist /custom-config /var/log/squid3
if [ "${SQUID_CONFIG_SOURCE}" != "" ]; then
echo "no configuration found -> use ${SQUID_CONFIG_SOURCE}/squidGuard.conf"
ln -s ${SQUID_CONFIG_SOURCE}/squidGuard.conf /etc/squidguard/squidGuard.conf
elif [ "${UPDATE_BLACKLIST_URL}" != "" ]; then
echo "no configuration found -> use /sample-config-blacklist"
ln -s /sample-config-blacklist/squidGuard.conf /etc/squidguard/squidGuard.conf
else
echo "no configuration found -> use /sample-config-simple"
ln -s /sample-config-simple/squidGuard.conf /etc/squidguard/squidGuard.conf
fi
fi
echo "running startSquidGuard with WPAD_IP=${WPAD_IP} WPAD_NOPROXY_NET=${WPAD_NOPROXY_NET} WPAD_NOPROXY_MASK=${WPAD_NOPROXY_MASK}"
if [ "${SQUID_CONFIG_SOURCE}" != "" ]; then
if [ -f ${SQUID_CONFIG_SOURCE}/wpad.dat ]; then
cp ${SQUID_CONFIG_SOURCE}/wpad.dat /var/www/html/
else
echo "wpad file ${SQUID_CONFIG_SOURCE}/wpad.dat does not exist. Use existing file."
fi
if [ -f ${SQUID_CONFIG_SOURCE}/block.html ]; then
cp ${SQUID_CONFIG_SOURCE}/block.html /var/www/html/
else
echo "wpad file ${SQUID_CONFIG_SOURCE}/wpad.dat does not exist. Use existing file."
fi
fi
if [ "${WPAD_IP}" != "" ]; then
sed 's/{{WPAD_IP}}/'"${WPAD_IP}"'/' -i /var/www/html/wpad.dat
sed 's/{{WPAD_NOPROXY_NET}}/'"${WPAD_NOPROXY_NET}"'/' -i /var/www/html/wpad.dat
sed 's/{{WPAD_NOPROXY_MASK}}/'"${WPAD_NOPROXY_MASK}"'/' -i /var/www/html/wpad.dat
fi
# start apache to serve wpad.dat file and or block.html
sudo /etc/init.d/apache2 restart
# run original squid start script
exec /sbin/entrypoint.sh