Optimization of adblock-lean

Fixed in the latest revision.
(also removed the popupads URL form the 'medium' preset, both in the code and in the proposed README)

1 Like

So looks like the above message was wrong: I fixed it in my code but forgot to git push, so the last 2 or 3 commits didn't make it into the merge.

Also looks like when updating from earlier versions, the automated config fix dialog doesn't work and that causes some errors.

The new PR fixes both issues and adds update simulation functionality to the update command, which should be useful in the future for testing before merge.

https://github.com/lynxthecat/adblock-lean/pull/79

1 Like

I’ve merged this in.

1 Like

What do you guys think about making a Github release? This might be good timing.

2 Likes

Just setup adblock-lean afresh having upgraded to OpenWrt 23.05.5. Beautiful flow. I hadn't experienced it for a while having always just reused my earlier config.

Here is what I saw:

root@OpenWrt-1:~# service adblock-lean start
Error: Config file is missing.
Generate default config using 'service adblock-lean gen_config'.

Error: Failed to load config.
root@OpenWrt-1:~# service adblock-lean gen_config

Based on the total usable memory of this device (490.72 MiB), the recommended preset is 'large':
Elements count: ~700k
blocklist_urls="https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/pro-onlydomains.txt https://raw.githubusercontent.com/hagezi/dns-blocklists/main/wildcard/tif-onlydomains.txt"
max_file_part_size_KB="30000"
max_blocklist_file_size_KB="50000"
min_good_line_count="200000"

[C]onfirm this preset or [p]ick another preset?
c|p: C

Please enter c|p

c|p: c

Cron job configuration:
A cron job can be created to enable automatic list updates.
The default schedule is '0 5 * * *': daily at 5am (5 o'clock at night)
The cron job will run with an added random number of minutes.

Create cron job with default schedule for automatic list updates?
'n' will set the 'cron_schedule' setting to 'disable'. You can later create a cron job with a custom schedule as described in:
https://github.com/lynxthecat/adblock-lean/blob/master/README.md
y|n: y

Generating new default config for adblock-lean from preset 'large'.

Saving new config file to '/etc/adblock-lean/config'.

Error: No appropriate 'addnmount' entry in /etc/config/dhcp was identified.
This is leveraged to give dnsmasq access to busybox gunzip to extract compressed blocklist.
Add: "list addnmount '/bin/busybox'" to /etc/config/dhcp at the end of the dnsmasq section.
Or simply run this command: uci add_list dhcp.@dnsmasq[0].addnmount='/bin/busybox' && uci commit
Either edit /etc/config/dhcp as described above or disable blocklist compression in config.

One question: should we just offer to add the appropriate line with the addnmount entry like we do so well with the cron task so as not to present the user with the (perhaps disconcerting) error about the addnmount on initial setup?

Currently the setup command creates the addnmount entry automatically, without asking the user. It was not created for you because you ran gen_config rather than setup. If you think creating the entry should be made optional, it's easy to implement.

1 Like

Ah, I've got you. Perhaps the present behaviour is just fine then.

1 Like

Are the last two lines of:

redundant based on the presence of /etc/adblock-lean? I forget how this works.

BTW the current README covers the sysupgrade scenario:

After completing sysupgrade, run the interactive setup again to re-enable adblock-lean: sh /etc/init.d/adblock-lean setup .

1 Like

Yep - I should have read the manual :smiley:!

1 Like

The last 2 lines will back up local allowlist and blacklist and then put them back. At least that's my understanding.

I'm trying to recall if incorporating a folder in the backup configuration means incorporating the files within the folder:

Who can answer? @dave14305?

BTW might an 'uninstall' option as in leave no trace be an idea? To remove adblock-lean I had to manually remove /etc/adblock-lean.

1 Like

Definitely a good idea. There is a slight issue with the addnmount entry, though: this entry might be used by other software. So automatically removing it during uninstall may break some functionality for the user. We could ask the user whether to remove it but I think most users would find this question highly technical and wouldn't know what to answer. Alternative approaches I can think of:

  • make a record during installation of whether addnmount was created and only if so then remove it during uninstallation
  • maybe there is a separate file we could create to extend the config, rather than editing /etc/config/dhcp? Then we could simply delete that file during uninstallation.
2 Likes

Backup folder alone should be enough. After upgrading from .3 to .5 my config file was kept, with this in the backup list:

# Preserve adblock-lean
/etc/adblock-lean
/etc/init.d/adblock-lean
/usr/libexec/abl_custom-script.sh

And actually I just noticed the "Open list..." button to preview what will be backed up, and all the files within /etc/adblock-lean are included on the list.

3 Likes

Then we should update the README with this information.

1 Like

Actually, maybe at the time of initial setup we could just add a new named config section, something along these lines:

config dnsmasq 'adblock-lean'
        list addnmount  '/bin/busybox'

Then when uninstalling, delete that section, recognized by its name (adblock-lean).
(not sure I remember the UCI syntax correctly)

Not sure if this works though.

2 Likes

Nice idea if that’d work.

Just tested - yep, this works (except it needs to be 'adblock_lean' in the UCI file because it won't accept '-'). Implementing the uninstall command now.

1 Like

Implemented the uninstall command in the latest revision (also fixed some bugs with the disable command).

1 Like