angry-squid/docker-stuff/start.sh

35 lines
846 B
Bash
Raw Permalink Normal View History

2019-08-05 16:40:59 +00:00
#!/bin/sh
SQUID_CACHE_DIR=${SQUID_CACHE_DIR:-/var/spool/squid}
SQUID_COREDUMP_DIR=${SQUID_COREDUMP_DIR:-/var/cache/squid}
SQUID_CACHE_SIZE_MB=${SQUID_CACHE_SIZE_MB:-10240}
2020-12-14 09:16:06 +00:00
SQUID_HOSTNAME=${SQUID_HOSTNAME:-angrysquid.local}
2019-08-05 16:40:59 +00:00
2019-09-10 13:28:47 +00:00
PIDFILE=/var/run/squid.pid
2019-08-05 16:40:59 +00:00
if [ ! -d "${SQUID_CACHE_DIR}" ]; then
mkdir -p "${SQUID_CACHE_DIR}"
chown squid:squid "${SQUID_CACHE_DIR}"
fi
if [ ! -d "${SQUID_COREDUMP_DIR}" ]; then
mkdir -p "${SQUID_COREDUMP_DIR}"
chown squid:squid "${SQUID_COREDUMP_DIR}"
fi
cat <<EOF >/etc/squid/conf.d/common.conf
cache_dir aufs ${SQUID_CACHE_DIR} ${SQUID_CACHE_SIZE_MB} 16 256
coredump_dir ${SQUID_COREDUMP_DIR}
2020-12-14 09:16:06 +00:00
visible_hostname ${SQUID_HOSTNAME}
2019-08-05 16:40:59 +00:00
EOF
if [ ! -d "${SQUID_CACHE_DIR}/00" ]; then
2019-09-10 13:28:47 +00:00
squid -z
2019-08-05 16:40:59 +00:00
sleep 5
fi
2019-09-10 13:28:47 +00:00
[ -e "${PIDFILE}" ] && rm "${PIDFILE}"
squid
2019-08-05 16:40:59 +00:00
tail -f /var/log/squid/access.log /var/log/squid/cache.log