I have changed the article so that the script resides in /usr/local/bin/hostsupdate instead of the user’s home directory, and gave it a better name. It makes more sense this way.
the necessity of hosts.head being present beforehand (and created manually) is mentioned in the article. I cannot automate ths process without complicated checks and taking the user’s freedom to have a customised hosts file (i.e. the head portion of it) but I added a check to the script that will make it fail if that file is not present.
Yes some preliminaries are required but tbf, it is possible to do everything on the device, without ssh.
I just used your script/timer approach and went with the ad block test site Test Ad Block - Toolz from 9% to 54% of blocked ads with the sailfish browser - pretty nice.
I get very similar results even with the strictest single list.
The developer of this tool also made this one. Not sure what the difference is, but it gives far less flattering results. I could not find any other differentiated & opensourced tools.
Using firebog.net’s meta list combined into one big hosts file I get +80% with both tools.
A slightly stricter µBlock configuration gives me 100% though, and µBlock gets a lot of its lists in AdBlock format. I will try to figure out how to best convert these to hosts format.
I reworked my hosts-based adblock script based on these insights:
If I use a combination of different hosts-based domain lists (as above) I get 87% and 65% resp. with those two test tools.
If I convert and add domains from ublock’s lists to that I get 91% and 87% resp., even though this adds “only” a few thousand unique entries.
Therefore the script has grown quite complex:
it converts uBO’s uAssets as far as possible to be used by /etc/hosts
it downloads everything from firebog.net’s meta list plus Steven Black’s largest hosts file
it combines and unique-sorts everything, adds a header and finally overwrites the old /etc/hosts
Ultimately it comes down to get a timely combination of as many sources as possible. I’m already re-inventing the wheel here; various more configurable solutions exist. But then, the whole thing is simple enough.
Keep in mind that uBO does more than domain blocking, and many adblock-specific rules can never be part of hosts-based blocking.
OTOH hosts-based blocking is always system-wide and very light on resources.
Adjust to your liking.
Copy the shell script to /usr/local/bin/hostsupdate and the systemd files to /etc/systemd/system.
Start & enable the timer: systemctl start --now hosts.timer && systemctl enable hosts.timer
Yes but it might take me a while. Thanks for the vote of confidence (well that’s how I choose to interpret it).
Good point, and done. Please check it out - it works for me. (my /bin/sh still points to busybox).
Dependencies: curl comes pre-installed afair.
Apart from that busybox has versions of all utils used: mktemp tar grep sed sort but I have no idea how to check which version the script actually uses?
Firefox with ublock is all I need. For Youtube I have Libretube, and I guess I could get streamlink to work somehow if I were so inclined to watch twitch streams and whatever.
I guess your /bin/sh is linked to bash. I have changed the offending bit now so it should work both with bash and busybox (see previous comments). Please try again.
It’s no bother. It should’ve been meta.list instead of meta-list. Fixed, pull again.
Btw and @everybody: this will result in pretty strict domain blocking. Not to everyone’s taste. If you want less maybe you can choose one of Steven Black’s ready-made files instead.
Just out of curiosity - isn’t it possible to create a rpm package from your scripts that can be put on openrepos/chum so everybody can install it easily without the need to ssh to the device?
Not everybody is able/willing to do this - but i guess everybody would appreciate an rpm package that could be easily installed via a store.
This issue has been just raised. A RPM package can run scripts but they are not designed for that task.
This kind of changes would go into something like a configuration manager but SFOS is missing completely such a tool. On the other hand, the tool that could have fulfill that role was Patch Manager but the evolution of PM gone in the direction of applying in-memory-only patches that do not survive to a reboot because otherwise a patch can mess up the system. This choice, as demonstrated in trying to patches some system configuration files, prevent to have a configuration manager tool with the minimum effort starting from the current PM.
However, because a configuration manager can potentially interfere also with the RPM installation / removing / update and for sure with the SFOS version upgrade no any way of applying persistent changes have been made but SSH. Hence, when you use SSH, it is your fault!
Welcome aboard, sailor!
It exists a package as described into DNS CACHING section of this guide