2022-02-15 09:55:45 -05:00
|
|
|
#!/usr/bin/env bash
|
2022-10-11 16:08:48 -04:00
|
|
|
# Set bash options
|
|
|
|
[ -n "$DEBUG" ] && set -x
|
|
|
|
set -o pipefail
|
|
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2022-02-16 17:39:19 -05:00
|
|
|
SQUID_USER="${SQUID_USER:-squid}"
|
2022-02-15 09:55:45 -05:00
|
|
|
SQUID_LOG_DIR="${SQUID_LOG_DIR:-/data/log/squid}"
|
2022-02-17 09:57:06 -05:00
|
|
|
REDIRECT_URL="${REDIRECT_URL:-}"
|
2022-02-16 17:52:35 -05:00
|
|
|
BLOCKLIST="${BLOCKLIST:-https://github.com/casjay/resources/raw/main/files/shallalist.tar.gz}"
|
2022-02-15 09:55:45 -05:00
|
|
|
BLOCKED_CATEGORIES="${BLOCKED_CATEGORIES:-adv,aggressive,porn,spyware,violence,warez}"
|
|
|
|
|
|
|
|
DB_LOCATION="/data/squidguard/db"
|
|
|
|
LOG_LOCATION="/data/log"
|
|
|
|
|
|
|
|
echo "Downloading blocklist..."
|
|
|
|
wget -q "${BLOCKLIST}" -O /tmp/blocklist.tgz
|
|
|
|
|
|
|
|
echo "Extracting blocklist..."
|
|
|
|
mkdir -p /tmp/blocklist
|
|
|
|
tar xzf /tmp/blocklist.tgz --strip-components=1 -C /tmp/blocklist
|
|
|
|
|
|
|
|
for CATEGORY in $(echo ${BLOCKED_CATEGORIES} | sed "s/,/ /g"); do
|
|
|
|
if [ ! -d "/tmp/blocklist/${CATEGORY}" ]; then
|
|
|
|
echo "Category ${CATEGORY} not available!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
cp -r "/tmp/blocklist/${CATEGORY}" "${DB_LOCATION}/"
|
|
|
|
done
|
|
|
|
|
|
|
|
NOT_LIST="${BLOCKED_CATEGORIES//,/ !}"
|
|
|
|
|
|
|
|
chown -R ${SQUID_USER}:${SQUID_USER} "${DB_LOCATION}"
|
|
|
|
chown -R ${SQUID_USER}:${SQUID_USER} "${LOG_LOCATION}"
|
|
|
|
chown -R ${SQUID_USER}:${SQUID_USER} "${CONFIG_FILE}"
|
|
|
|
|
|
|
|
echo "Cleanup..."
|
|
|
|
rm -rf /tmp/*
|
2022-02-16 19:05:31 -05:00
|
|
|
|
|
|
|
squid -k reconfigure
|