[Script] Update AdGuard Home

Hi there :wave:

some people wonder how to update the AdGuard Home version on devices like the Flint or Flint2. For your convenience, I created a script to automate this process. Make sure to read and understand this post before you go on!

Permanent feature

I added the option to make all changes permanent. The script therefore only needs to be executed once, the effects are then permanent. Even across firmware updates. On the downside, it might create trouble when you flash a way older firmware.

If everything fails, flashing using Uboot will fix it.

Dependencies

Currently, the update-process is only supported on devices using ARM64 or ARMv7 architecture.
This should affect most routers like the Flint or Flint2. If you are not sure about the architecture, you can run uname -m to get the current one. It should say aarch64 or armv7l to be able to run my script.

I added some checks in my script as well, so it should be pretty safe to run. :crossed_fingers:

Download

You can find it in my repo located on GitHub:

Quick run without downloading

You can run it without cloning the repository by using the following command:

wget -O update-adguardhome.sh https://raw.githubusercontent.com/Admonstrator/glinet-adguard-updater/main/update-adguardhome.sh && sh update-adguardhome.sh

Running on devices with low free space

You can use --ignore-free-space to ignore the free space check. This is useful for devices with low free space like the AXT1800.

In that case, there will be no backup of the original files and the script will not check if there is enough free space to download the new files. Could potentially break your router if there is not enough free space.

Enabling query logging

By default, AdGuard Home is not able to save the query log to a file. This is to prevent running out of space on the router and prevent wearing out the flash memory. This script can enable query logging to file by setting the querylog option in the AdGuard Home configuration file. You will asked if you want to enable query logging after the update.

If you want to enable query logging to file without updating AdGuard Home, you can run the following command:


sed -i '/^querylog:/,/^[^ ]/ s/^ file_enabled: .*/ file_enabled: true/' /etc/AdGuardHome/config.yaml

/etc/init.d/adguardhome restart

For disabling query logging to file, you can run the following command:


sed -i '/^querylog:/,/^[^ ]/ s/^ file_enabled: .*/ file_enabled: false/' /etc/AdGuardHome/config.yaml

/etc/init.d/adguardhome restart

Selecting a release

By default, the script will install the latest stable release of AdGuard Home. You can use --select-release to select a specific release. The script will ask you which release you want to install.

Disclaimer

This script is provided as is and without any warranty. Use it at your own risk.

It may break your router, your computer, your network or anything else.
It may even burn down your house :fire: You have been warned!

Reverting

Since AdGuard Home is deeply integrated into the firmware, it is difficult to revert the changes. Right now there is no automatic way to revert them. Resetting the router to factory settings will NOT revert the changes if you choose to make the installation persistent!

How to revert the changes manually by SSH:

  1. Remove the line /usr/bin/enable-adguardhome-update-check from /etc/rc.local.

  2. Execute rm /usr/bin/enable-adguardhome-update-check to remove the script.

  3. Remove the following lines from /etc/sysupgrade.conf:

    • /root/AdGuardHome_backup.tar.gz
    • /etc/AdGuardHome
    • /usr/bin/AdGuardHome
    • /usr/bin/enable-adguardhome-update-check
    • /etc/rc.local
  4. Stop the AdGuard Home service by executing /etc/init.d/adguardhome stop.

  5. Reset the AdGuard Home configuration by executing rm -rf /etc/AdGuardHome - this will remove all your settings and blocklists!

  6. Start the AdGuard Home service by executing /etc/init.d/adguardhome start.

A backup of the original files is located in the /root/ folder. The backup is named AdGuardHome_backup.tar.gz.

If you still encounter issues after doing these steps, you can reset AdGuard Home to its original state by flashing the firmware again.

17 Likes

@slesar Maybe you want to give it a try? :wink:

2 Likes

Does this procedure survive after updating the firmware?

Yep, that’s why I created it.

1 Like

Cool, I’ll be testing it here and giving feedback, the tailscale script works fine here on the MT6000, I saw that you have another one from Acme, do you have a post on how to use it?

Na, this one is pretty useless so far because I did not implement renewal of certificates (yet).
I’ll make a post about it as soon as it’s ready for testing.

All of my scripts do have readme.md where everything is written down. Same for the acme one.

@japa182 or here:

1 Like

Can anyone post a video of how to do this update for newbe like me.

1 Like

You need learn how to use shh console then follow guide 1st post.
@admon maybe add paragraph about how to use shh with link? :thinking:

I will do test after my work. Thanks for scripting. I recommend first backup “config.yaml” which saved setting for adguard home IP addresses and block list filters. Make sure last line has different version “scheme number”.

2 Likes

I am curious about your result.
Backing up those files is already integrated. They will be backed up to /root/AdGuardHome_Backup.tar.gz

1 Like

I tested and did not update the latest version of Adguard Home.
Result console:


Still showing available to update:
image

May you reboot your router once?

I did not reboot router :sweat_smile:


22 days :exploding_head:
I don’t think to reboot. Let me try manual switch off adguard home in gl ui.

Yes, the manual does work. Toggle “Enable Adgaurd Home” then Apply.
image
So one script does not stop service Adguard Home

1 Like

Thanks, I added a command to make sure that AGH is killed for real now.

1 Like

12 posts were split to a new topic: AdGuard Home - Upstream servers not reachable

Tip of the hat to ya @admon. Works like a charm! I’m using a GL-MT2500.

Hi, thanks for your work @admon. It worked on my GL-MT3000.

1 Like

The script worked well also on Brume2, thanks @admon

How the embedded softwares are handled by GL-inet?
I mean, I noticed ADGuard on Brume2 was from March/2023. One year old.
Since then, many security updates were released, but none of them were applied by GL-inet?

The answer is: Not very well.

They should learn with you how to do, because it’s a really concern to have many softwares out-of-date with no security patches applied.

If they don’t like to update absolutely nothing, they should give an easy solution for all customers do that by themselves.

2 Likes