#!/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 LOGFILE="${WRK_DIR}/pull.log" if [ ! -f "$LOGFILE" ] ; then touch "$LOGFILE" fi