Skip to content

Instantly share code, notes, and snippets.

@captainhook
Last active March 24, 2023 19:06
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save captainhook/f4ccfc82dc6696270d62b54b13f871c4 to your computer and use it in GitHub Desktop.
Save captainhook/f4ccfc82dc6696270d62b54b13f871c4 to your computer and use it in GitHub Desktop.
#!/bin/bash
# This script will download and add the Spotify whitelist to your pihole
# Adapted from https://github.com/anudeepND/whitelist/blob/master/scripts/whitelist.sh
# Make sure you are pulling the latest raw of pi-hole compatible whitelist: https://gist.github.com/captainhook/9eb4132d6e58888e37c6bc6c73dd4e60
# This is INCOMPATIBLE WITH UPCOMING Pihole v5
#====================================================
TICK="[\e[32m ✔ \e[0m]"
PIHOLE_LOCATION="/etc/pihole"
GRAVITY_UPDATE_COMMAND="pihole -g"
echo -e " \e[1m This script will download and add domains from the repo to whitelist.txt \e[0m"
sleep 1
echo -e "\n"
if [ "$(id -u)" != "0" ] ; then
echo "This script requires root permissions. Please run this as root!"
exit 2
fi
curl -sS https://gist.githubusercontent.com/captainhook/9eb4132d6e58888e37c6bc6c73dd4e60/raw/34caa169dccbb5814b08abe224e01ebdb7cedd67/SpotifyWhitelist | sudo tee -a "${PIHOLE_LOCATION}"/whitelist.txt >/dev/null
echo -e " ${TICK} \e[32m Adding domains to whitelist... \e[0m"
sleep 0.1
echo -e " ${TICK} \e[32m Removing duplicates... \e[0m"
mv "${PIHOLE_LOCATION}"/whitelist.txt "${PIHOLE_LOCATION}"/whitelist.txt.old && cat "${PIHOLE_LOCATION}"/whitelist.txt.old | sort | uniq >> "${PIHOLE_LOCATION}"/whitelist.txt
echo -e " [...] \e[32m Pi-hole gravity rebuilding lists. This may take a while... \e[0m"
${GRAVITY_UPDATE_COMMAND} > /dev/null
echo -e " ${TICK} \e[32m Pi-hole's gravity updated \e[0m"
echo -e " ${TICK} \e[32m Done! \e[0m"
echo -e " \e[1m Happy AdBlocking :)\e[0m"
echo -e "\n\n"
@makew0rld
Copy link

makew0rld commented Oct 31, 2020

For modern Pi-Hole, just use this:

curl -sSL https://gist.github.com/captainhook/9eb4132d6e58888e37c6bc6c73dd4e60/raw/34caa169dccbb5814b08abe224e01ebdb7cedd67/SpotifyWhitelist | sed 's/#.*//; /^[[:space:]]*$/d' | xargs -n1 pihole -w

@YenLegion
Copy link

@makeworld-the-better-one Replace in the script, or only your one-liner?

@captainhook
Copy link
Author

@makeworld-the-better-one thanks!
@YenLegion just the one-liner will work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment