pihole_lists/set_env.sh
robocopAlpha 4e52559f79 simplified updates
as the idea is to generate blocklists daily, the update package will be downloaded daily without checksum. Easier this way.
Can implement checksum of the update package if needed.
2021-07-16 03:40:56 +03:00

50 lines
1.3 KiB
Bash

#!/usr/bin/env bash
# Functions
fetch_hosts(){
URL=$1
FNAME=$2
curl -sSL "${URL}" | rg -INv "^[#]|localhost" | sd '\s+$' '' | sd "^0\\.0\\.0\\.0 |^127\\.0\\.0\\.1 " "" | sd "\\#.*" "" >| ${FNAME}
}
fetch_blocklist(){
URL=$1
FNAME=$2
curl -sSL "${URL}" | rg -INv "^[#]|localhost" | sd '\s+$' '' | sd "\\#.*" "" >| ${FNAME}
}
#--- Pick fastest cat command (based on my experience)
if command -v gcat > /dev/null 2>&1; then
catCMD='gcat' # GNU cat /usr/local/bin/gcat
# (To get run: brewlog insall coreutils)
elif alias mcat > /dev/null 2>&1; then
catCMD='mcat' # mcat is aliased to /bin/cat that ships with macOS
else
catCMD=$(command -v cat) # If none of the above are found then vanilla cat
fi
#--- Set parameters based on Distribution
if [ "$(uname)" == "Darwin" ]; then
# echo "Setting params for Darwin..."
# getMD5(){
# # usage: getMD5 'filename' > outfile
# echo "$(md5 -q ${1})"
# }
HOME_DIR=/Users/deepankar/OneDrive\ -\ O365\ Turun\ yliopisto/Git/Gitlab.DC
elif [ "$(uname)" == "Linux" ]; then
# echo "Setting params for Linux..."
# getMD5()
# {
# # usage: getMD5 'filename' > outfile
# echo "$(md5sum ${1} | cut -c -32)"
# }
HOME_DIR=/home/dietpi
else
echo "Only MacOS and Linux are supported."
exit 1
fi
WRK_DIR=${HOME_DIR}/pihole_lists