What's new

Troubleshoot adblock script

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

bazzly

Occasional Visitor
I was wondering if someone could give me a hand...

I have modified the script for "How to Remove Advertisements with Pixelserv on DD-WRT" And solved a lot of the errors. However I still do not have it functioning correctly.

When the script runs at reboot I get locked out of the WebIF

This is the output at boot

Dec 31 19:00:15 ad_blocker_script: ###########Ads blocker ed###########
Dec 31 19:00:15 ad_blocker_script: Sleeping for 30 secs to give time for router boot
Dec 31 19:00:15 ad_blocker_script: New IP and ports setup
Dec 31 19:00:46 ad_blocker_script: The web-GUI is already setup
Dec 31 19:00:46 ad_blocker_script: Adding a refresh cycle by puting the script in cron if it isnt there yet
Dec 31 19:00:46 ad_blocker_script: Redirect setup & Appending to the FW script
Dec 31 19:00:46 ad_blocker_script: did NOT find an active redirect rule with the iptable command, injecting it now.
Dec 31 19:00:46 ad_blocker_script: The FW script is already in place
Dec 31 19:00:46 ad_blocker_script: Starting or ReSpawning pixelsrv
Dec 31 19:00:46 ad_blocker_script: it seems that the pixelserv isnt up. starting it now
Dec 31 19:00:46 pixelserv[663]: /jffs/scripts/dns/pixelserv V19 compiled: Nov 4 2010 23:54:44 from pixelserv19.c
Dec 31 19:00:46 pixelserv[665]: Abort: Address already in use
Dec 31 19:00:46 ad_blocker_script: Get the online lists
Dec 31 19:00:46 ad_blocker_script: The lists are less then 3 days old, saving on flash erosion and NOT refreshing them
Dec 31 19:00:46 ad_blocker_script: Injecting the DNSMasq nvram options with the dynamic block lists
Dec 31 19:00:46 ad_blocker_script: The DNSMaq options are already in place
Dec 31 19:00:46 ad_blocker_script: Checking if the personal list is a file
Dec 31 19:00:46 ad_blocker_script: The personal list (assuming there is one) is not in a file
Dec 31 19:00:46 ad_blocker_script: Final settings implementer
Dec 31 19:00:46 ad_blocker_script: Nothing to commit
Dec 31 19:00:46 ad_blocker_script: ##########The Ads blocker script has finished its run and you should up and running##########

The script is attached.. Any ideas??

This part in the log has me wondering...
pixelserv[665]: Abort: Address already in use
 

Attachments

  • disable_adds .txt
    9.4 KB · Views: 503
Last edited:
That script will probably require a few changes to work under Asuswrt-merlin. For instance I see in your log that the script is trying to modify the dnsmasq settings through nvram - unlike DD-WRT, we do not store config stuff into nvram. You will have to use a custom config file instead (See the Github Wiki for the details).

However it's restarting dnsmasq will also be totally different between Asuswrt and DD-WRT. Best would probably be to signal dnsmasq telling it to reload its config. Otherwise, kill it, and run "dnsmasq --log-async".
 
Thanks for the info.. I'm going into unfamiliar Territory for myself..I was gonna bang away at this but dont have a lot of time to mess with it, so I'll chip away at it here and there.

On a side note, as nice as this would be to have this running right now I may give Privoxy a go... and return to the script at some point..

Thanks again
 
Looks like I'm back to the script lol... Privoxy is not the solution I'm looking for.

Looks like I have a bit of learning to do... Could you point me to the area you think I should look at in the Github Wiki, I took a look, but perhaps I'm looking at the wrong stuff...

I think it would be in this bit of code..

fi

logger_ads "Injecting the DNSMasq nvram options with the dynamic block lists"
nvram get dnsmasq_options > /tmp/dns-options.tmp
if [[ -z "`cat /tmp/dns-options.tmp | grep "/jffs/scripts/dns/dnsmasq.adblock.conf"`" || -z "`cat /tmp/dns-options.tmp | grep "/jffs/scripts/dns/dlhosts"`" && -e /jffs/scripts/dns/dnsmasq.adblock.conf ]] ; then
logger_ads "Did not find DNSMsaq options in nvram and adding them now"
echo "conf-file=/jffs/scripts/dns/dnsmasq.adblock.conf" >> /tmp/dns-options.tmp
echo "addn-hosts=/jffs/scripts/dns/dlhosts" >> /tmp/dns-options.tmp
nvram set aviad_changed_nvram=1
logger_ads "Added options to nvram DNSMasq options"
else
logger_ads "The DNSMaq options are already in place"
fi

logger_ads "Checking if the personal list is a file"
if [[ -z "`cat /etc/dnsmasq.conf | grep conf-file=/jffs/scripts/dns/personal-ads-list.conf`" && -z "`nvram get dnsmasq_options | grep "/jffs/scripts/dns/personal-ads-list.conf"`" && -e /jffs/scripts/dns/personal-ads-list.conf ]] ; then
logger_ads "Yes the personal list is in the form of a file"
logger_ads "Removing whitelist from the personal file"
cat /jffs/scripts/dns/whitelist | while read line; do sed -i /${line}/d /jffs/scripts/dns/personal-ads-list.conf ; done
echo "conf-file=/jffs/scripts/dns/personal-ads-list.conf" >> /tmp/dns-options.tmp
nvram set aviad_changed_nvram=1
else
[ ! -e /jffs/scripts/dns/personal-ads-list.conf ] && logger_ads "The personal list (assuming there is one) is not in a file"
[ -n "`nvram get dnsmasq_options | grep "/jffs/scripts/dns/personal-ads-list.conf"`" ] && logger_ads "The personal list is a file, and... it is already in place according to the NVRAM options readout"
[ $1 = "-f" ] && cat /jffs/scripts/dns/whitelist | while read line; do sed -i /${line}/d /jffs/scripts/dns/personal-ads-list.conf ; done && logger_ads "overide switch given so removed whitelist from personal file"
fi

logger_ads "Final settings implementer"
if [ "`nvram get aviad_changed_nvram`" -eq 1 ] ; then
nvram set dnsmasq_options="`cat /tmp/dns-options.tmp`"
logger_ads "Found that NVRAM was changed and committing changes now"
nvram commit
nvram set aviad_changed_nvram=0
logger_ads "Refreshing DNS settings"
stopservice dnsmasq && logger_ads "stopped the dnsmasq service"
startservice dnsmasq && logger_ads "started the dnsmasq service"
else
logger_ads "Nothing to commit"
fi
rm /tmp/dns-options.tmp
 
Last edited:
So did anyone get the ad blocking working in the wiki? (I spent hours trying to get it to work with complete fail.)

Anyone want to try and help me get this working..?

I can post what I have changed so far...

On a side note... In the script I have a line "nvram get dnsmasq_options > /tmp/dns-options.tmp"
I know " > /tmp/dns-options.tmp" part is fine... How do I go about the first part? nvram get dnsmasq_options... Should it be something like..

/jffs/configs/dnsmasq.conf.add get dnsmasq_options > /tmp/dns-options.tmp

I think If I get that section working... it may jut work...(Until I find something else broken..lol)
 
Last edited:
So I gave /jffs/configs/dnsmasq.conf.add a go and that does not see to work...

ad_blocker_script: Injecting the DNSMasq /jffs/configs/dnsmasq.conf.add options with the dynamic block lists
ad_blocker_script: Did not find DNSMsaq options in /jffs/configs/dnsmasq.conf.add and adding them now
ad_blocker_script: Added options to /jffs/configs/dnsmasq.conf.add DNSMasq options
ad_blocker_script: Checking if the personal list is a file
cat: can't open '/tmp/dnsmasq.conf': No such file or directory

I look in the dnsmasq.conf.add and it has nothing it it.

Where is the dnsmasq.conf? Should I be placing this in tmp?
Looks like grep doesnt want to work now... hmm
Attached is the full output, if anyone can give me a clue.

Thanks
 

Attachments

  • output.txt
    4.5 KB · Views: 533
Is there anyone in this forum, that would like to help me with this? If not please let me know, and I can try to look else where.. Thanks. :)
 
Hi,

I can help re the pixelserv bit, dd-wrt web gui hogs all router ips with the web port - that's why the script moves the router ip off port 80, but it inserts an iptables redirect so that accessing the router ip on port 80 gets redirected to new web interface port 81.

Tomatousb httpd code was modified so that it only listens on router ip port 80, so pixelserv can also use port 80 on a secondary ip.

I don't know what restrictions there are on rmerlin/asuswrt router gui, but presumably it doesn't use those dd-wrt nvram vars to change the port, and then pixelserv can't start start its listener.

An alternative would be to start pixelserv listening on the different port/ secondary ip (and divert ads to it), I used this mode for testing but its not usually compiled in. By the way v19 had some issues, latest is V30 (posted on linksysinfo site).

Re dnsmasq, there is a major potential issue - if the config file (autoparsed from internet blocklists) has an error dnsmsaq dies, the tomato adblock script tries to detect this and deinstalls), not sure about the dd-wrt one. Breaking router dns service makes you very unpopular with your users!

Tomato adblock script kills main router dnsmasq instance and starts its own, an alternative would be to tell dnsmasq via custom script to look in a custom folder - and just delete the folder contents and reload dnsmasq to escape.
 
Wow.. Thanks for the insight... Perhaps I'm a bit over my head then... hmm

Not having a working Adblock on this router make me dislike using this setup very much, and may be reverting back to DDWRT (linksys e4200).
I so want this to work, but it's been a fight.

So with that being said...not sure where I would even start on this. (but I'd like too).

Once again, Thanks for the info... I didnt think anyone was going to reply at this point.

I will attempt to do a little reading when I have a few.

Thanks
 

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top