-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
45 lines (39 loc) · 1 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
44
45
#!/bin/bash
set -e
create_log_dir() {
mkdir -p ${SQUID_LOG_DIR}
chmod -R 755 ${SQUID_LOG_DIR}
chown -R ${SQUID_USER}:${SQUID_USER} ${SQUID_LOG_DIR}
}
create_cache_dir() {
mkdir -p ${SQUID_CACHE_DIR}
chown -R ${SQUID_USER}:${SQUID_USER} ${SQUID_CACHE_DIR}
}
apply_backward_compatibility_fixes() {
if [[ -f /etc/squid/squid.user.conf ]]; then
rm -rf /etc/squid/squid.conf
ln -sf /etc/squid/squid.user.conf /etc/squid/squid.conf
fi
}
create_log_dir
create_cache_dir
apply_backward_compatibility_fixes
# allow arguments to be passed to squid3
if [[ ${1:0:1} = '-' ]]; then
EXTRA_ARGS="$@"
set --
elif [[ ${1} == squid3 || ${1} == $(which squid3) ]]; then
EXTRA_ARGS="${@:2}"
set --
fi
# default behaviour is to launch squid
if [[ -z ${1} ]]; then
if [[ ! -d ${SQUID_CACHE_DIR}/00 ]]; then
echo "Initializing cache..."
$(which squid3) -N -f /etc/squid/squid.conf -z
fi
echo "Starting squid3..."
exec $(which squid3) -f /etc/squid/squid.conf -NYCd 1 ${EXTRA_ARGS}
else
exec "$@"
fi