From a592716528e89614bae1a4332cd7bac0b54c5a17 Mon Sep 17 00:00:00 2001 From: Andros Fenollosa Date: Mon, 19 Aug 2024 20:54:48 +0200 Subject: [PATCH] Fix: https://github.com/tanrax/maza-ad-blocking/issues/27 --- README.md | 18 +++++++++--------- maza | 16 +++++++++++++--- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index ba339f9..760c59d 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Simple, native and efficient **local ad blocker**. Bash script compatible with * ### 📡 Update database ``` bash -maza update +sudo maza update ``` ### 🔨 Start @@ -59,7 +59,7 @@ sudo maza stop ### ⚖️ Status ``` bash -maza status +sudo maza status ``` ## ⚙️ Install or Update @@ -106,12 +106,12 @@ TERM=dumb ## 🔪 Uninstall ``` bash -sudo rm /usr/local/bin/maza && sudo rm -r ~/.config/maza +sudo rm /usr/local/bin/maza && sudo rm -r /root/.config/maza ``` ## 🚫 Not blocking certain domains -Edit `~/.config/maza/ignore` and add the domains you want to ignore. +Edit `/root/.config/maza/ignore` and add the domains you want to ignore. Example: @@ -140,12 +140,12 @@ ip6-allhosts Finally update Maza to apply the changes. ``` bash -maza update +sudo maza update ``` ## 🎯 Add custom domains to block -If you want to include your own domains to be blocked, you can add them to `~/.config/maza/custom-domains`. They must each be on one line, ignoring end slash or protocol (`http` or `https`). +If you want to include your own domains to be blocked, you can add them to `/root/.config/maza/custom-domains`. They must each be on one line, ignoring end slash or protocol (`http` or `https`). For example: @@ -158,7 +158,7 @@ ad.about.com Then update the database to regenerate the list to include your domains. ``` -maza update +sudo maza update ``` ## 🔒 Alternative DNS list @@ -182,7 +182,7 @@ Unfortunately the hosts file does **not support sub-domains (wildcards)**, which #### 0 Update Maza ```bash -maza update +sudo maza update ``` #### 1 Install @@ -248,7 +248,7 @@ sudo maza start #### 0 Update Maza ```bash -maza update +sudo maza update ``` #### 1 Install diff --git a/maza b/maza index 26b5e73..cc25a73 100755 --- a/maza +++ b/maza @@ -134,6 +134,19 @@ update() { # Remove empty lines custom-sed -i.bak '/^$/d' "$CONFIG$LIST" + # Update HOST_FILE + ## Remove old list + custom-sed -i "/$START_TAG/,/$END_TAG/d" "$HOST_FILE" + ## Add List to host file. + # Add start tag DNS list in first line + echo "$START_TAG" >> "$HOST_FILE" + echo "$PROJECT" >> "$HOST_FILE" + echo "$AUTHOR" >> "$HOST_FILE" + # Transform "mydomain.com" to "127.0.0.1 mydomain.com" except comments + custom-sed "/^#/!s/^/127.0.0.1 /g" "$CONFIG$LIST" >> "$HOST_FILE" + # Add end tag DNS list in first line + echo "$END_TAG" >> "$HOST_FILE" + # Make dnsmasq format cp "$CONFIG$LIST" "$CONFIG$LIST_DNSMASQ" ## Remove triple "-". Example: "my---domain.com" to "my-domain.com". Only in dnsmasq. @@ -165,9 +178,6 @@ update() { start() { update - # Add List to host file. - # Transform "mydomain.com" to "127.0.0.1 mydomain.com" except comments - custom-sed "/^#/!s/^/127.0.0.1 /g" "$CONFIG$LIST" >> "$HOST_FILE" # Notify user echo "${COLOR_GREEN}ENABLED!${COLOR_RESET}" }