mirror of
https://gitlab.com/robocopAlpha/pihole_lists.git
synced 2026-05-17 18:42:16 -07:00
71 lines
2.5 KiB
Bash
Executable file
71 lines
2.5 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
# ------- How to use ------:
|
|
# curl -L 'https://gitlab.com/robocopAlpha/pihole_lists/-/raw/master/update.pi.sh' | bash
|
|
|
|
|
|
# --------- Make alias ---- :
|
|
# echo "alias update.pi='curl -L "https://gitlab.com/robocopAlpha/pihole_lists/-/raw/master/update.pi.sh" | bash'" >> .bashrc
|
|
|
|
# echo "alias update.pi='curl -L "https://gitlab.com/robocopAlpha/pihole_lists/-/raw/master/update.pi.sh" | bash'" >> .zshrc
|
|
|
|
|
|
# ----- Begin Script ------
|
|
|
|
# creating directory if it doesn't exist.
|
|
if cd /home/dietpi/pihole > /dev/null ; then
|
|
echo "[✓]homedir exists..."
|
|
else
|
|
mkdir -p /home/dietpi/pihole
|
|
fi
|
|
# installing xz if it doesn't exit
|
|
|
|
if which xz > /dev/null ; then
|
|
echo "[✓]package xz-utils found..."
|
|
else
|
|
apt update; apt install xz-utils
|
|
fi
|
|
|
|
cd /home/dietpi/pihole
|
|
|
|
LOGFILE="/home/dietpi/pihole/update.log"
|
|
|
|
if [ ! -f "$LOGFILE" ] ; then
|
|
# Creating brew.log
|
|
echo "Creating $LOGFILE"
|
|
mkdir -p "$(dirname "$LOGFILE")"
|
|
touch "$LOGFILE"
|
|
fi
|
|
|
|
echo "pihole being udpdated on: $(date)" | tee -a "$LOGFILE"
|
|
|
|
chksum_web=$(curl -sL 'https://www.dropbox.com/s/dl/78gc475jdil8cx7/MyBlocklist.checksum')
|
|
chksum_local=$(md5sum MyBlocklist.txt | cut -c -32)
|
|
if [ -f MyBlocklist.txt ] && [ "$chksum_web" == "$chksum_local" ]; then
|
|
echo "${GREEN}MyBlocklist Unchanged. Skipping download.${NC}" 2>&1 | tee -a "$LOGFILE"
|
|
else
|
|
echo "${CYAN}Getting Myblocklist${NC}" 2>&1 | tee -a "$LOGFILE"
|
|
curl -OJL 'https://www.dropbox.com/s/dl/yh3y87ue0x3a8ac/MyBlocklist.txt.xz'
|
|
xz -fd MyBlocklist.txt.xz
|
|
fi
|
|
chksum_web=$(curl -sL 'https://www.dropbox.com/s/dl/bxwqegi7umy4io1/facebook_block.checksum')
|
|
chksum_local=$(md5sum facebook_block.txt | cut -c -32)
|
|
if [ "$chksum_web" == "$chksum_local" ] && [ -f facebook_block.txt ]; then
|
|
echo "${GREEN}Facebook blocklist Unchanged. Skipping download.${NC}" 2>&1 | tee -a "$LOGFILE"
|
|
else
|
|
echo "${CYAN}Getting Facebook blocklist${NC}" 2>&1 | tee -a "$LOGFILE"
|
|
curl -OJL 'https://www.dropbox.com/s/dl/xrsg5gswmzfsdd9/facebook_block.txt.xz'
|
|
xz -fd facebook_block.txt.xz
|
|
fi
|
|
|
|
curl -OJL 'https://gitlab.com/robocopAlpha/pihole_lists/-/raw/main/whitelist.txt'
|
|
grep "^[^#]" whitelist.txt | sort -u | uniq | tr '\r\n' ' ' >| whitelist
|
|
rm -f whitelist.txt
|
|
$(command -v pihole) -w --nuke > /dev/null 2>&1 | tee -a "$LOGFILE"
|
|
$(command -v pihole) -w -q -nr $(cat whitelist) 2>&1 | tee -a "$LOGFILE"
|
|
rm whitelist
|
|
$(command -v pihole) updateGravity 2>&1 | tee -a "$LOGFILE"
|
|
|
|
# Add these to pihole adlist
|
|
# file:///home/dietpi/pihole/MyBlocklist.txt
|
|
# file:///home/dietpi/pihole/facebook_block.txt
|