rubfi / esphole

Ad blocker for ESP
97 stars 17 forks source link

Generation Script Errors on Mac #4

Open rotkohlsuppe opened 1 year ago

rotkohlsuppe commented 1 year ago

Hi, thank you for your effort. I installed it on my Wemos D1 Mini and it works very well and fastern then expected. Unfortunately I've had problems with the script. I'm on macos 10.14.6. I had to change a bit to make it work.

#!/bin/bash
# Script for downloading and converting the ad server lists to smaller files

HOSTS_URL="https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&mimetype=plaintext&useip=0.0.0.0"
#HOSTS_URL="http://someonewhocares.org/hosts/zero/hosts"

#edit: your personal sketchbook folder
PATH_ARDUINO_SKETCHBOOK="/Users/XYZ/Arduino"
#edit if your esphole repo is not located in the sketch folder or was renamed already:
HOSTS_TEMP_DIR=$PATH_ARDUINO_SKETCHBOOK"/esphole-master/utils/temp"

mkdir -p $HOSTS_TEMP_DIR
HOST_LIST="$HOSTS_TEMP_DIR/host_list"

wget $HOSTS_URL -O - | grep -v '#' | grep "0.0.0.0" | sed 's/0\.0\.0\.0 //g' > $HOST_LIST

# saves each domain in a file depending on its characters
for i in $(cat $HOST_LIST)
do
    x=$(echo -n $i | tr '\n' ' ' | tr "\r" " ")
    name=$(echo -n $x | wc -m)
    echo -n ",$x" >> hosts_$(echo -n $name)
done

# adds a kind of EOF for making easier the findUntil
for i in $(ls -1 hosts_*)
do
    echo ",@@@" >> $i
done

mkdir -p $HOSTS_TEMP_DIR/../../data
mv hosts_* $HOSTS_TEMP_DIR/../../data/