🦈🏠🐜 Initial Commit 🐜🦈🏠

This commit is contained in:
Jason
2022-02-15 09:55:45 -05:00
commit b096089188
322 changed files with 62596 additions and 0 deletions

72
bin/create-blocklists.sh Executable file
View File

@@ -0,0 +1,72 @@
#!/usr/bin/env bash
set -ex
SQUID_USER="${SQUID_USER:-squid}"
SQUID_LOG_DIR="${SQUID_LOG_DIR:-/data/log/squid}"
REDIRECT_URL="${REDIRECT_URL:-/}"
BLOCKLIST="${BLOCKLIST:-http://www.shallalist.de/Downloads/shallalist.tar.gz}"
BLOCKED_CATEGORIES="${BLOCKED_CATEGORIES:-adv,aggressive,porn,spyware,violence,warez}"
CONFIG_FILE="/etc/squidguard/squidGuard.conf"
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
echo "Creating config file..."
rm "${CONFIG_FILE}"
touch "${CONFIG_FILE}"
echo "dbhome ${DB_LOCATION}" >>"${CONFIG_FILE}"
echo "logdir ${LOG_LOCATION}" >>"${CONFIG_FILE}"
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}/"
echo "dest ${CATEGORY} {" >>"${CONFIG_FILE}"
if [ -e "${DB_LOCATION}/${CATEGORY}/domains" ]; then
echo " domainlist ${CATEGORY}/domains" >>"${CONFIG_FILE}"
fi
if [ -e "${DB_LOCATION}/${CATEGORY}/urls" ]; then
echo " urllist ${CATEGORY}/urls" >>"${CONFIG_FILE}"
fi
if [ -e "${DB_LOCATION}/${CATEGORY}/expressions" ]; then
echo " expressionlist ${CATEGORY}/expressions" >>"${CONFIG_FILE}"
fi
echo "}" >>"${CONFIG_FILE}"
done
NOT_LIST="${BLOCKED_CATEGORIES//,/ !}"
{
echo "acl {"
echo " default {"
echo " pass !${NOT_LIST} all"
echo " redirect $REDIRECT_URL"
echo " }"
echo "}"
} >>"${CONFIG_FILE}"
squidGuard -C all
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/*

69
bin/entrypoint-squid.sh Executable file
View File

@@ -0,0 +1,69 @@
#!/usr/bin/env bash
set -e
if [ "$1" = "healthcheck" ]; then
squidclient -h localhost cache_object://localhost/counters
exit $?
fi
SQUID_USER="${SQUID_USER:-squid}"
SQUID_LOG_DIR="${SQUID_LOG_DIR:-/data/log/squid}"
SQUID_CACHE_DIR="${SQUID_CACHE_DIR:-/data/cache/squid}"
HOSTNAME="${HOSTNAME:-$(hostname -f)}"
mkdir -p "/config" "/data"
for dir in apache2 e2guardian squid squidguard; do
if [ -f "/usr/local/share/squidFiles/$dir" ]; then
cp -Rf "/usr/local/share/squidFiles/$dir" "/config/$dir"
elif [ -d "/usr/local/share/squidFiles/$dir" ]; then
cp -Rf "/usr/local/share/squidFiles/$dir/." "/config/$dir/"
else
cp -Rf "/usr/local/share/squidFiles/data/." "/data/"
cp -Rf "usr/local/share/squidFiles/config/." "/config/"
fi
done
mkdir -p "${SQUID_LOG_DIR}" "${SQUID_CACHE_DIR}"
mkdir -p "/data/log/squidguard" "/data/log/e2guardian" "/data/squidguard/db"
chown -Rf ${SQUID_USER}:${SQUID_USER} "/config" "/data"
chmod -Rf 755 "${SQUID_LOG_DIR}"
cp -Rf "/config/." "/etc/"
if [ "${UPDATE_BLACKLIST_URL}" != "" ]; then
sudo wget -O backlist.tar.gz ${UPDATE_BLACKLIST_URL} &&
tar -xzf backlist.tar.gz -C "/data/squidguard/db" &&
rm -Rf backlist.tar.gz &&
chown -Rf ${SQUID_USER}:${SQUID_USER} "/data/squidguard/db"
fi
if [ "${WPAD_IP}" != "" ]; then
sed 's/{{WPAD_IP}}/'"${WPAD_IP}"'/' -i "/data/htdocs/www/wpad.dat"
sed 's/{{WPAD_NOPROXY_NET}}/'"${WPAD_NOPROXY_NET}"'/' -i "/data/htdocs/www/wpad.dat"
sed 's/{{WPAD_NOPROXY_MASK}}/'"${WPAD_NOPROXY_MASK}"'/' -i "/data/htdocs/www/wpad.dat"
fi
# allow arguments to be passed to squid
if [[ ${1:0:1} = '-' ]]; then
EXTRA_ARGS="$@"
set --
elif [[ ${1} == squid || ${1} == $(which squid) ]]; then
EXTRA_ARGS="${@:2}"
set --
fi
# start apache to serve wpad.dat file and or block.html
sudo /etc/init.d/apache2 restart
# default behaviour is to launch squid
if [[ -z ${1} ]]; then
if [[ ! -d ${SQUID_CACHE_DIR}/00 ]]; then
echo "Initializing cache..."
$(which squid) -N -f /etc/squid/squid.conf -z
fi
echo "Starting squid..."
exec $(which squid) -f /etc/squid/squid.conf -NYCd 1 ${EXTRA_ARGS}
else
exec "$@"
fi