mirror of
https://gitlab.com/robocopAlpha/pihole_lists.git
synced 2026-05-17 18:42:16 -07:00
64 lines
No EOL
1.8 KiB
Bash
Executable file
64 lines
No EOL
1.8 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
WRK_DIR=/home/dietpi/pihole_lists
|
|
cd ${WRK_DIR}/
|
|
|
|
rm -rf /home/dietpi/onedrive
|
|
mkdir /home/dietpi/onedrive
|
|
|
|
rclone mount --daemon onedrive:Temp/blocklist/ /home/dietpi/onedrive
|
|
|
|
# Fetch blocklists
|
|
bash ${WRK_DIR}/get_blocklists.sh
|
|
if [ $? -ne 0 ]; then
|
|
echo "Failed to get blocklists. Execution terminated!"
|
|
exit
|
|
fi
|
|
|
|
# Block FB
|
|
source ${WRK_DIR}/block_FB.sh
|
|
|
|
#--- 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
|
|
#-----------
|
|
|
|
# Combining blocklists
|
|
${catCMD} ${WRK_DIR}/Mirrors/* | sort -u | uniq >| ${WRK_DIR}/MyBlocklist.txt
|
|
wc -l ${WRK_DIR}/MyBlocklist.txt
|
|
|
|
echo -e "\nAdding these to my own Blacklist: \n"
|
|
${catCMD} ${WRK_DIR}/blocked | rg -vIN "^[\\#]" | sd '\s+$' '' | sort -u | uniq >> ${WRK_DIR}/MyBlocklist.txt
|
|
echo -e " $(wc -l ${WRK_DIR}/MyBlocklist.txt) unique domains. \n"
|
|
|
|
#-------
|
|
# Clean-up
|
|
rm -rf ${WRK_DIR}/Mirrors
|
|
rm -f ${WRK_DIR}/blocklists/MyBlocklist.txt.xz ${WRK_DIR}/blocklists/facebook_block.txt.xz
|
|
mkdir ${WRK_DIR}/blocklists
|
|
mv ${WRK_DIR}/*.txt ${WRK_DIR}/blocklists/.
|
|
|
|
#--------
|
|
# Archiving
|
|
cd ${WRK_DIR}/blocklists/
|
|
echo $(date +%d.%m.%y-%H:%M:%S) >| lastpull
|
|
md5sum ${WRK_DIR}/blocklists/MyBlocklist.txt | cut -c -32 >| MyBlocklist.checksum
|
|
md5sum ${WRK_DIR}/blocklists/facebook_block.txt | cut -c -32 >| facebook_block.checksum
|
|
sleep 1
|
|
xz -v -T4 MyBlocklist.txt
|
|
xz -v -T4 facebook_block.txt
|
|
|
|
|
|
#---------
|
|
# Moving to target
|
|
cd ..
|
|
mv -f ${WRK_DIR}/blocklists/* /home/dietpi/onedrive/.
|
|
cp -f dump.whitelist /home/dietpi/onedrive/dump.whitelist
|
|
rmdir ${WRK_DIR}/blocklists
|
|
sudo umount /home/dietpi/onedrive |