Skip to content

Commit

Permalink
Merge pull request #13 from deividgdt/develop/main
Browse files Browse the repository at this point in the history
Version 3.7
  • Loading branch information
deividgdt authored Sep 10, 2021
2 parents 1b580c0 + 81970d1 commit e1d8952
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions ytadsblocker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# This script was made in order to block all the Youtube's advertisement in Pi-Hole

YTADSBLOCKER_VERSION="3.6"
YTADSBLOCKER_VERSION="3.7"
YTADSBLOCKER_LOG="/var/log/ytadsblocker.log"
YTADSBLOCKER_GIT="https://raw.githubusercontent.com/deividgdt/ytadsblocker/master/ytadsblocker.sh"
VERSIONCHECKER_TIME="280"
Expand All @@ -17,6 +17,7 @@ SCRIPT_NAME=$(basename $0)
PRINTWD=$(pwd)
SQLITE3BIN=$(whereis -b sqlite3 | cut -f 2 -d" ")
TEMPDIR="/tmp/ytadsblocker"
CONFIGFILE="/etc/pihole/.ytadsblocker.cfg"
DOCKER_PIHOLE="/etc/docker-pi-hole-version"
ROOT_UID=0
NORMALPATTERN='r([0-9]{1,2})[^-].*\.googlevideo\.com'
Expand Down Expand Up @@ -120,6 +121,16 @@ function Database() {
esac
}

function LoadConfiguration(){
# We check if the file exists
if [ -f ${CONFIGFILE} ]; then

# First we get the pattern chosen by the user
export PATTERN=$(grep 'current_pattern' ${CONFIGFILE} | cut -f 2 -d'=')

fi
}



function Install() {
Expand All @@ -135,12 +146,15 @@ function Install() {
case $answer in
Y|y)
PATTERN=${AGGRESSIVEPATTERN}
echo "current_pattern=${PATTERN}" >> ${CONFIGFILE}
;;
N|n)
PATTERN=${NORMALPATTERN}
echo "current_pattern=${PATTERN}" >> ${CONFIGFILE}
;;
*)
PATTERN=${NORMALPATTERN}
echo "current_pattern=${PATTERN}" >> ${CONFIGFILE}
;;
esac

Expand Down Expand Up @@ -210,9 +224,10 @@ function Install() {
}

function Start() {

CheckUser #We check if the root user is executing the script

LoadConfiguration #We load the main configuration from the file ${CONFIGFILE}

echo "Youtube Ads Blocker Started"
echo "Check the $YTADSBLOCKER_LOG file to get further information."

Expand Down Expand Up @@ -302,6 +317,11 @@ function Uninstall() {
fi
fi

if [ -f ${CONFIGFILE} ]; then
echo -e "${TAGINFO} Deleting config file..."
rm --force ${CONFIGFILE}
fi

echo -e "${TAGOK} YouTube Ads Blocker Uninstalled. Bye"
kill -9 `pgrep ytadsblocker`

Expand All @@ -323,3 +343,4 @@ case "$1" in
"uninstall" ) Uninstall ;;
* ) echo "That option does not exists. Usage: ./$SCRIPT_NAME [ install | start | stop | uninstall ]";;
esac

0 comments on commit e1d8952

Please sign in to comment.