English Forums > Tutorials and FAQs

HOWTO - Update AdGuard Home automatically with cron

(1/2) > >>

Vexz:
This tutorial assumes you have installed AGH through mimugmail's community repo (tutorial link).

The gist of this tutorial is to install updates of AGH and restart its running instance with a cronjob automatically.

ATTENTION: You'll need AdGhuard Home v0.107.22 er newer to make this work. In earlier versions the update parameter didn't exist yet or was buggy.

------------------------------------------------------------------

1. Connect to your OPNsense via SSH

2. To make life easier use
--- Code: ---# sudo -i
--- End code ---

3. In the menu where you have to choose an option use "8" (Shell)

4. Edit the following config (I chose vi to do that):

--- Code: ---# vi /usr/local/opnsense/service/conf/actions.d/actions_adguardhome.conf
--- End code ---

5. In this config you need to add the [update] part. See below:

--- Code: ---[start]
command:/usr/local/etc/rc.d/adguardhome start
parameters:
type:script
message:starting Adguardhome

[stop]
command:/usr/local/etc/rc.d/adguardhome stop
parameters:
type:script
message:stopping Adguardhome

[restart]
command:/usr/local/etc/rc.d/adguardhome restart
parameters:
type:script
message:restarting Adguardhome
description:Restart AdGuardHome service

[status]
command:/usr/local/etc/rc.d/adguardhome status;exit 0
parameters:
type:script_output
Message:request Adguardhome status

[update]
command:/usr/local/AdGuardHome/./AdGuardHome --update
parameters:
type:script
message:updating Adguardhome
description:Update AdGuard Home

--- End code ---

6. Restart configd

--- Code: ---# service configd restart
--- End code ---
This will add a new selectable option in the drop down menu for "Command" in the web UI under System > Settings > Cron. Add a cronjob with this option for when you want AGH to update.


7. Install AGH as a service. You will need this to make AGH automatically restart after a new update was installed. The "--no-check-update" is optional and should hinder AGH from searching for new updates. Somehow this doesn't work in my case.

--- Code: ---# /usr/local/AdGuardHome/./AdGuardHome -s install --no-check-update
--- End code ---

8. Make the AGH service start at boot. For this we need to create a new file.

--- Code: ---# touch /usr/local/etc/rc.syshook.d/start/50-adguardhome
# chmod 755 /usr/local/etc/rc.syshook.d/start/50-adguardhome
# vi /usr/local/etc/rc.syshook.d/start/50-adguardhome

--- End code ---
Now paste the following in this file and save:

--- Code: ---#!/bin/sh

/usr/local/AdGuardHome/./AdGuardHome -s start

--- End code ---

9. In the web UI you need to disable AGH or you'll have two instances of AGH running after a reboot. For this navigate to Services > Adguardhome > General. Uncheck the checkmark for "Enable" and hit "Save".

10. Reboot your OPNsense to confirm the AGH service is starting on boot. After the reboot you should be able to access the web UI of AGH. Give AGH a few seconds to start. The CLI of your OPNsense should output "service: running" when you execute this command:

--- Code: ---# /usr/local/AdGuardHome/./AdGuardHome -s status
--- End code ---

11. Done!

------------------------------------------------------------------

I couldn't find out which file to edit to make the checkmark in the web UI start the AGH service, not an individual instance. Maybe someone more experienced than me can help me out and I'll add it to the tutorial.

cookiemonster:
Need is the mother of invention. But the approach IMHO should be _not_ to hack around the plugin.
How can the developer out of his/her free time support installations of the plugin that have subsequently modified?
Or anyone seeking assistance from the community for that matter?. But you will do what you will.

From my part, when I need to update AdGH plugin installation, all I have to do is click on "upgrade" on the AdGH UI page. The only minor issue is that an OPN healthcheck will report a file sig mismatch.
Is that something that doesn't work for you?

Vexz:

--- Quote from: cookiemonster on February 16, 2023, 04:47:23 pm ---Need is the mother of invention. But the approach IMHO should be _not_ to hack around the plugin.
How can the developer out of his/her free time support installations of the plugin that have subsequently modified?
Or anyone seeking assistance from the community for that matter?. But you will do what you will.

--- End quote ---
Nobody is forced setup auto updates for AGH. I just wanted to make a tutorial in case someone is looking for a solution for that.  Also I asked mimugmail a few weeks ago if he wants to update his repo to add this option but didn't get a answer. So I did it myself.


--- Quote from: cookiemonster on February 16, 2023, 04:47:23 pm ---From my part, when I need to update AdGH plugin installation, all I have to do is click on "upgrade" on the AdGH UI page. The only minor issue is that an OPN healthcheck will report a file sig mismatch.
Is that something that doesn't work for you?

--- End quote ---
It works for me too but I love automation because I don't wanna think about updating every service I use. Also I like figuring stuff like that out. It's fun to me and I learn more about OPNsense.

cookiemonster:
But with this you are not automating the updates of the plugin instance but creating a new plumbing for the instance, on the same system and away from the UI. Therefore not a solution to the "problem", which we've estblished doesn't exist.
For your purposes, all good but my critique is about having a suitable large notice that is an unsupportable way to hack at the plugin.
I can already see cases of multiple instances running (someone forgot to go and disabled the actual plugin instance from the UI) and all sorts of strange behaviours coming from that.
BTW, good work for your learning. It isn't intended as criticism despite what it might appear.

Vexz:
You can easily revert the changes or create a ZFS snapshot before making any changes to the system.
Of course it's just "plumbing" because I modify a plugin. But what can I do? It's not like I didn't try to ask the maintainer of the repo to implement this feature. I could have kept this tutorial to myself but maybe someone else was looking for this solution but couldn't figure out how to make it work.

Navigation

[0] Message Index

[#] Next page

Go to full version