List auto update (hosts)

Hello

I am using this list as hosts file.

https://raw.githubusercontent.com/hagezi/dns-blocklists/main/hosts/ultimate.txt

I want to automate its updates without installing any new plugins like Adblock. I want to make it using only built-in features.

It is added not as main (as additional) hosts file, works perfectly. But I need to automate auto update. Like each reboot (reboot timer set n).

Probably use WGET or CURL? Is there anyone who can help to achieve that?

Add cron job to fetch it and update it on intervals of your choice.

1 Like

It needs to be updated only on reboot :sweat_smile:

The OpenWrt cron does not support @reboot
So you need to go through init.d instead.

1 Like

How? What to enter there?

Then , login into LuCi and add your command in rc.local.

1 Like

Can you provide as detailed guide as possible?
How to download file in exact folder? Or replace old one with new one?

/etc/rc.local is a script that gets run at every boot.

You can edit it using normal tools and add your commands to it.

1 Like

So what to add there?

#!/bin/sh /etc/rc.common

START=99
STOP=10

start() {
    wget -O /tmp/hosts https://raw.githubusercontent.com/hagezi/dns-blocklists/main/hosts/ultimate.txt && \
    mv /tmp/hosts /path/to/hosts/file
}

stop() {
}

chmod +x /etc/init.d/script.sh
/etc/init.d/script.sh enable
1 Like