From c2dbfdb04eacc5260f46abe0143f3c8620de18a8 Mon Sep 17 00:00:00 2001 From: Andros Fenollosa Date: Fri, 3 Jan 2020 09:50:01 +0100 Subject: [PATCH] Update update function --- maza | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/maza b/maza index 0198cb2..58d6eda 100755 --- a/maza +++ b/maza @@ -6,6 +6,8 @@ set -e PROGNAME=$(basename $0) CONFIG=($HOME/.maza/) LIST="list" +START_TAG="## MAZA - List ad blocking" +END_TAG="## END MAZA" # FUNCTIONS @@ -38,7 +40,19 @@ update() { # Download DNS list curl -L -s "https://pgl.yoyo.org/adservers/serverlist.php?showintro=0;hostformat=hosts" -o "$CONFIG/$LIST" # Clear list - sed -n "/
/,/<\/pre>/p" list > "$CONFIG/$LIST"
+    ## Get PRE tag
+    sed -i .bak -n "/
/,/<\/pre>/p" "$CONFIG/$LIST"
+    ## Remove first line
+    sed -i .bak '1d' "$CONFIG/$LIST"
+    ## Remove last line
+    sed -i .bak '$ d' "$CONFIG/$LIST"
+    ## Add start tag DNS list in first line
+    sed -i .bak "1i\\
+        $START_TAG
+        " "$CONFIG/$LIST"
+    ## Add end tag DNS list in first line
+    echo $END_TAG >> "$CONFIG/$LIST"
+    # Notify user
     echo "Done!"
 }