Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I wrote an auto install script based on your instructions #146

Open
slyfox1186 opened this issue Dec 10, 2023 · 3 comments
Open

I wrote an auto install script based on your instructions #146

slyfox1186 opened this issue Dec 10, 2023 · 3 comments

Comments

@slyfox1186
Copy link

Thought I would share it. Seems to work great for me.

You just create the script...

#!/usr/bin/env bash

clear

# youTube_ads_4_pi-hole-installer.sh

random_dir="$(mktemp -d)"
gravity="$(find /etc/ -type f -name 'gravity.db')"
yt_adlist="${random_dir}/yt-adlist.txt"
c1='youTube_ads_4_pi-hole -- github.com/kboghdady/youTube_ads_4_pi-hole'

#
# REMOVE LEFTOVER FOLDERS FROM PREVIOUS ATTEMPTS/RUNS
#

if [ -d 'youTube_ads_4_pi-hole' ]; then
    rm -fr 'youTube_ads_4_pi-hole'
fi

#
# GIT CLONE THE REPO
#

git clone 'https://github.com/kboghdady/youTube_ads_4_pi-hole.git'
cd 'youTube_ads_4_pi-hole' || exit 1

#
# CHANGE A VARIABLE IN THE SCRIPT
#

sed -i 's/repoDir=\$(pwd)/repoDir="\${PWD}"/g' 'youtube.sh'

#
# MAKE THE SCRIPT EXECUTABLE
#

chmod a+x 'youtube.sh'

#
# ADD CRONTAB ENTRY TO AUTO-UPDATE THE SCRIPT
#

is_in_cron="${PWD}/youtube.sh"
cron_entry=$(crontab -l 2>&1) || exit
new_cron_entry="0 */1 * * * ${PWD}/youtube.sh 2>&1"

if [[ "${cron_entry}" != *"${is_in_cron}"* ]]; then
  printf '%s\n' "${cron_entry}" "${new_cron_entry}" | crontab -
fi

#
# ADD URL TO PIHOLE'S ADLISTS
#

echo 'https://raw.githubusercontent.com/kboghdady/youTube_ads_4_pi-hole/master/youtubelist.txt' > "${yt_adlist}"
cat < "${yt_adlist}" | xargs -I{} sqlite3 "${gravity}" 2>/dev/null \
    "INSERT OR IGNORE INTO adlist (address, comment) VALUES ('{}',\"${c1}\")"

#
# UPDATE PIHOLE'S GRAVITY AND RESTARTDNS
#

pihole -g
pihole restartdns

#
# DELETE THE RANDOM TMP DIRECTORY
#

rm -fr "${random_dir}"

Then you run these commands...

sudo chmod a+x youTube_ads_4_pi-hole-installer.sh
sudo bash youTube_ads_4_pi-hole-installer.sh
@RedYellowGM
Copy link

Hi, can you give a step by step guide on how to install the scritpt? I think I've made some mistakes, because I still see ads on youtube. Thanks

@Spartan1776
Copy link

Thought I would share it. Seems to work great for me.

@slyfox1186, as of 05/17/2024, is this repo still blocking YouTube ads for you? The README could use a clarity upgrade (haha...), but I don't really want to invest the time if this doesn't even work. I would assume it works (dangerous, I know), but the last commit was two years ago, so I don't know how relevant this is.

The reason I ask is that everything I've read so far seems to indicate that both videos and ad pulls come from the same source, so it's impossible to use a DNS blocklist to block ads without blocking the video itself, too. If this works, though, it'd be a game-changer for me.

Thanks for your help, and thanks for the script!

@slyfox1186
Copy link
Author

slyfox1186 commented May 23, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants