Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flag for updating from the command line #4223

Closed
ainar-g opened this issue Jan 28, 2022 · 15 comments
Closed

Flag for updating from the command line #4223

ainar-g opened this issue Jan 28, 2022 · 15 comments

Comments

@ainar-g
Copy link
Contributor

ainar-g commented Jan 28, 2022

(Split from #4219).

We need a command line flag to perform an update without the need to enable / use the Web API. Something like ./AdGuardHome --update.

@ainar-g ainar-g added this to the v0.108.0 milestone Jan 28, 2022
@ainar-g ainar-g self-assigned this Jan 28, 2022
@Mizzick Mizzick modified the milestones: v0.108.0, v0.107.19 Nov 15, 2022
@ainar-g ainar-g closed this as completed Nov 23, 2022
@ainar-g ainar-g modified the milestones: v0.107.20, v0.107.19 Nov 23, 2022
@Vexz00
Copy link

Vexz00 commented Nov 23, 2022

How exactly does this work now? I use the --update option and the console seems to be stuck doing nothing.
Shouldn't it be checking for an update and if there is no update available telling something like "There's no new update." or something? It's confusing to me.

Edit:
I think I get it now. It starts an instance of AGH with automatic silent updates, right? Will I experience timeouts for DNS queries during an update of AGH or is the update fast enough to not run into timeouts?

Edit 2:
So here the description for the --update argument is "Update application and exit.". What does "and exit" exactly mean here? Does it stop the AGH service? I don't see why anyone would want that. But I can't think of anything else what "and exit" would mean.

@webmihir
Copy link

How exactly does this work now? I use the --update option

Same question. I am trying to see if I can integrate this into a nightly CRON job by calling /opt/AdguardHome/AdguardHome --update. However similar to the previous poster's observation, the console is stuck and never returns.

@Vexz00
Copy link

Vexz00 commented Nov 24, 2022

I am trying to see if I can integrate this into a nightly CRON job by calling /opt/AdguardHome/AdguardHome --update.

That was exactly my plan but I think it's just an argument when launching AGH and it will automatically update AGH when it finds an update. Not quite what I was looking for because I don't want to run into DNS query timeouts when I actively need AGH during the day.

@elandorr
Copy link

elandorr commented Dec 7, 2022

Same here. The description in --help says it will update and exit, but it does literally nothing.

My 'workflow' is as follows for windows clients if anyone cares:

  1. see new stable on git
  2. download
  3. verify sig
  4. AdGuardHome.exe -s uninstall
  5. replace file
  6. AdGuardHome -s install --no-check-update (installs the service with -s run --no-check-update)

Automatic connections are unwanted here.

An improvement would be:

  1. see new stable on git
  2. run AdGuardHome.exe --update
  3. agh downloads and verifies the signature
  4. agh replaces itself and keeps the --no-check-update flag for the service

Cheers

@wesley800
Copy link

wesley800 commented Dec 12, 2022

LOL seems not usable at all. I'm stucked too.

Actually, for the update to successfully run (at least on Linux), one must shutdown any running AdGH instance. Otherwise the code will stuck at bbolt.Open. To be more specific, bbolt is designed to not allow multiple instance. See bbolt/db.go:230:if err := flock(db, !db.readOnly, options.Timeout); err != nil { and the comment above it for details.

BTW debugging with GDB on golang program is more than painful with the totally-no-accuracy breakpoints.

@ainar-g Would you please reopen this issue?

@ainar-g ainar-g reopened this Dec 15, 2022
@ainar-g ainar-g modified the milestones: v0.107.19, v0.107.22 Dec 15, 2022
@ainar-g ainar-g assigned Mizzick and unassigned ainar-g Dec 15, 2022
@EugeneOne1 EugeneOne1 assigned EugeneOne1 and unassigned Mizzick Dec 30, 2022
adguard pushed a commit that referenced this issue Jan 9, 2023
Merge in DNS/adguard-home from 5191-update-flag to master

Updates #5191.
Updates #4223.

Squashed commit of the following:

commit fbace49
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Mon Jan 9 12:05:16 2023 +0400

    all: imp code, docs

commit 8237dce
Merge: ca9518f bbdcc67
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Fri Dec 30 14:45:55 2022 +0400

    Merge branch 'master' into 5191-update-flag

commit ca9518f
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Dec 29 20:36:33 2022 +0400

    home: imp code

commit 1dc6c7c
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Dec 29 18:26:08 2022 +0400

    all: imp code, docs

commit 7bbe893
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Dec 29 03:44:48 2022 +0400

    home: restart service on update

commit e0d3c28
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Dec 29 03:22:49 2022 +0400

    all: update on first run

commit 0aa4e78
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Dec 29 02:47:30 2022 +0400

    all: move some code to init less

commit 68aebfa
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Dec 29 00:36:00 2022 +0400

    WIP

commit 2c7fb97
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed Dec 28 14:15:59 2022 +0400

    home: imp logs

commit 4b06d08
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Dec 27 19:21:17 2022 +0400

    all: fix update flag
@EugeneOne1
Copy link
Member

EugeneOne1 commented Jan 9, 2023

@Vexz00, @webmihir, @elandorr, @wesley800, hello again. We've published the edge release which should fix the --update flag. Could you please check it out? Also keep in mind that the proper update needs the next release to be published, however AdGuard Home now shouldn't freeze even in case the release is absent.

@EugeneOne1
Copy link
Member

Well, I'll close the issue for now if you don't mind, since we've been able to succesfully test it on our machines. Please feel free to reopen it if you'll face any issues with our fixed implementation.

@webmihir
Copy link

webmihir commented Jan 17, 2023

Well, I'll close the issue for now if you don't mind, since we've been able to succesfully test it on our machines. Please feel free to reopen it if you'll face any issues with our fixed implementation.

I'm sorry I forgot to respond over there long weekend. Yes I can confirm this is working on edge. Looking forward to this making it's way to 108 along with the actual fix!

@elandorr
Copy link

Thanks, I'll test it on the next update as well!

@ainar-g ainar-g modified the milestones: v0.107.23, v0.107.22 Jan 19, 2023
@Vexz00
Copy link

Vexz00 commented Jan 20, 2023

Sorry for the late reply. I tried it earlier today and it looks like it would work if there was a new update available.

But I have one question left: Will it update an already running instance of AGH so we can make a cron job to automatically update and completely forget about it? This would be a dream come true since this would mean I wouldn't have to do anything anymore and AGH is always up to date.

@EugeneOne1
Copy link
Member

@Vexz00, it'll actually only try to restart the service if the one installed.

@elandorr
Copy link

elandorr commented Feb 6, 2023

I tested it today with the new update.

  • If run with root permissions, the service definition is not touched, so the --no-check-update stays intact.
  • If run without root permissions, the error message about the service is wrong, but it couldn't know any better. It did finish and replace the binary I think, but it can't have restarted the service, so it'll probably crash sooner or later.

Seems like it works fine. You can update when you explicitly want to update, without additional unwanted network activity, and without manually visiting github/unpacking/etc.

Does this verify signature based on the initial binary, though? That seems pretty critical.

We set it up once, verify your sig, and it then continues to rotate. Otherwise, if you're ever taken over, having this without human oversight seems risky. If you do it manually, there's a bigger chance you may notice the github repo is weird.

@ainar-g
Copy link
Contributor Author

ainar-g commented Feb 6, 2023

@elandorr, please file a separate issue about that.

@elandorr
Copy link

elandorr commented Feb 6, 2023

About what? This is just the promised feedback for when there's a new update.

@Vexz00
Copy link

Vexz00 commented Feb 16, 2023

@Vexz00, it'll actually only try to restart the service if the one installed.

And that's fine because with the start of the service an instance of AGH is started too. That means when there's a new update it'll install the update and restart the service which also restarts AGH. Everything is working fine this way. Only a manually started instance of AGH doesn't get restarted.

heyxkhoa pushed a commit to heyxkhoa/AdGuardHome that referenced this issue Mar 20, 2023
Merge in DNS/adguard-home from 5191-update-flag to master

Updates AdguardTeam#5191.
Updates AdguardTeam#4223.

Squashed commit of the following:

commit fbace49
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Mon Jan 9 12:05:16 2023 +0400

    all: imp code, docs

commit 8237dce
Merge: ca9518f bbdcc67
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Fri Dec 30 14:45:55 2022 +0400

    Merge branch 'master' into 5191-update-flag

commit ca9518f
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Dec 29 20:36:33 2022 +0400

    home: imp code

commit 1dc6c7c
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Dec 29 18:26:08 2022 +0400

    all: imp code, docs

commit 7bbe893
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Dec 29 03:44:48 2022 +0400

    home: restart service on update

commit e0d3c28
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Dec 29 03:22:49 2022 +0400

    all: update on first run

commit 0aa4e78
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Dec 29 02:47:30 2022 +0400

    all: move some code to init less

commit 68aebfa
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Thu Dec 29 00:36:00 2022 +0400

    WIP

commit 2c7fb97
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Wed Dec 28 14:15:59 2022 +0400

    home: imp logs

commit 4b06d08
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Dec 27 19:21:17 2022 +0400

    all: fix update flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants