mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-08-16 22:20:30 +03:00
Pull request: all: updater exe name
Merge in DNS/adguard-home from 4219-updater to master
Squashed commit of the following:
commit f569a5f232330b83c234838a5bff8ae5277f152f
Merge: a90b4fa7 3505ce87
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date: Thu Jul 7 22:14:50 2022 +0530
Merge remote-tracking branch 'origin/master' into 4219-updater
# Conflicts:
# CHANGELOG.md
commit a90b4fa7782c5ec4531d8e305c0d448e84898239
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date: Thu Jul 7 21:56:17 2022 +0530
home: imp code
commit da0f96b976e430fffc531072ef3e2384bc8b1f09
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date: Thu Jul 7 21:48:40 2022 +0530
updater: exe name
commit 246dc9ca3b133cbc93ea59edd272674b87ff8de3
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date: Thu Jul 7 19:18:02 2022 +0530
all: imp docs
commit 042382d170c4d68ff67fe5544a75371337529623
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date: Thu Jul 7 18:02:25 2022 +0530
all: updater exe name
commit a180c4673ead66788969865784348634af1a739e
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date: Thu Jul 7 17:47:46 2022 +0530
docs: updater exe name
commit 1a98a6eadbd96add0a488fb8f89fb7d8b0ffb3d0
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date: Thu Jul 7 17:40:44 2022 +0530
all: updater exe name
commit 1b13f5d85550dc71b08fd8e5b4258f8414a38759
Author: Dimitry Kolyshev <dkolyshev@adguard.com>
Date: Thu Jul 7 17:14:57 2022 +0530
all: updater exe name
This commit is contained in:
parent
3505ce8739
commit
77e5e27d75
@ -32,6 +32,8 @@ and this project adheres to
|
||||
|
||||
### Fixed
|
||||
|
||||
- Updater no longer expects a hardcoded name for `AdGuardHome` executable
|
||||
([#4219]).
|
||||
- Inconsistent names of runtime clients from hosts files ([#4683]).
|
||||
- PTR requests for addresses leased by DHCP will now be resolved into hostnames
|
||||
under `dhcp.local_domain_name` ([#4699]).
|
||||
@ -39,6 +41,7 @@ and this project adheres to
|
||||
|
||||
[#2993]: https://github.com/AdguardTeam/AdGuardHome/issues/2993
|
||||
[#3057]: https://github.com/AdguardTeam/AdGuardHome/issues/3057
|
||||
[#4219]: https://github.com/AdguardTeam/AdGuardHome/issues/4219
|
||||
[#4677]: https://github.com/AdguardTeam/AdGuardHome/issues/4677
|
||||
[#4683]: https://github.com/AdguardTeam/AdGuardHome/issues/4683
|
||||
[#4699]: https://github.com/AdguardTeam/AdGuardHome/issues/4699
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"syscall"
|
||||
"time"
|
||||
@ -180,11 +179,10 @@ func finishUpdate(ctx context.Context) {
|
||||
cleanup(ctx)
|
||||
cleanupAlways()
|
||||
|
||||
exeName := "AdGuardHome"
|
||||
if runtime.GOOS == "windows" {
|
||||
exeName = "AdGuardHome.exe"
|
||||
curBinName, err := os.Executable()
|
||||
if err != nil {
|
||||
log.Fatalf("executable path request failed: %s", err)
|
||||
}
|
||||
curBinName := filepath.Join(Context.workDir, exeName)
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
if Context.runningAsService {
|
||||
@ -192,7 +190,7 @@ func finishUpdate(ctx context.Context) {
|
||||
// we can't restart the service via "kardianos/service" package - it kills the process first
|
||||
// we can't start a new instance - Windows doesn't allow it
|
||||
cmd := exec.Command("cmd", "/c", "net stop AdGuardHome & net start AdGuardHome")
|
||||
err := cmd.Start()
|
||||
err = cmd.Start()
|
||||
if err != nil {
|
||||
log.Fatalf("exec.Command() failed: %s", err)
|
||||
}
|
||||
@ -204,14 +202,14 @@ func finishUpdate(ctx context.Context) {
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
err := cmd.Start()
|
||||
err = cmd.Start()
|
||||
if err != nil {
|
||||
log.Fatalf("exec.Command() failed: %s", err)
|
||||
}
|
||||
os.Exit(0)
|
||||
} else {
|
||||
log.Info("Restarting: %v", os.Args)
|
||||
err := syscall.Exec(curBinName, os.Args, os.Environ())
|
||||
err = syscall.Exec(curBinName, os.Args, os.Environ())
|
||||
if err != nil {
|
||||
log.Fatalf("syscall.Exec() failed: %s", err)
|
||||
}
|
||||
|
@ -111,7 +111,12 @@ func (u *Updater) Update() (err error) {
|
||||
log.Info("updater: updating")
|
||||
defer func() { log.Info("updater: finished; errors: %v", err) }()
|
||||
|
||||
err = u.prepare()
|
||||
execPath, err := os.Executable()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = u.prepare(filepath.Base(execPath))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -162,7 +167,8 @@ func (u *Updater) VersionCheckURL() (vcu string) {
|
||||
return u.versionCheckURL
|
||||
}
|
||||
|
||||
func (u *Updater) prepare() (err error) {
|
||||
// prepare fills all necessary fields in Updater object.
|
||||
func (u *Updater) prepare(exeName string) (err error) {
|
||||
u.updateDir = filepath.Join(u.workDir, fmt.Sprintf("agh-update-%s", u.newVersion))
|
||||
|
||||
_, pkgNameOnly := filepath.Split(u.packageURL)
|
||||
@ -173,13 +179,13 @@ func (u *Updater) prepare() (err error) {
|
||||
u.packageName = filepath.Join(u.updateDir, pkgNameOnly)
|
||||
u.backupDir = filepath.Join(u.workDir, "agh-backup")
|
||||
|
||||
exeName := "AdGuardHome"
|
||||
updateExeName := "AdGuardHome"
|
||||
if u.goos == "windows" {
|
||||
exeName = "AdGuardHome.exe"
|
||||
updateExeName = "AdGuardHome.exe"
|
||||
}
|
||||
|
||||
u.backupExeName = filepath.Join(u.backupDir, exeName)
|
||||
u.updateExeName = filepath.Join(u.updateDir, exeName)
|
||||
u.updateExeName = filepath.Join(u.updateDir, updateExeName)
|
||||
|
||||
log.Debug(
|
||||
"updater: updating from %s to %s using url: %s",
|
||||
@ -188,7 +194,6 @@ func (u *Updater) prepare() (err error) {
|
||||
u.packageURL,
|
||||
)
|
||||
|
||||
// TODO(a.garipov): Use os.Args[0] instead?
|
||||
u.currentExeName = filepath.Join(u.workDir, exeName)
|
||||
_, err = os.Stat(u.currentExeName)
|
||||
if err != nil {
|
||||
|
@ -131,7 +131,7 @@ func TestUpdate(t *testing.T) {
|
||||
u.newVersion = "v0.103.1"
|
||||
u.packageURL = fakeURL.String()
|
||||
|
||||
require.NoError(t, u.prepare())
|
||||
require.NoError(t, u.prepare("AdGuardHome"))
|
||||
|
||||
u.currentExeName = filepath.Join(wd, "AdGuardHome")
|
||||
|
||||
@ -209,7 +209,7 @@ func TestUpdateWindows(t *testing.T) {
|
||||
u.newVersion = "v0.103.1"
|
||||
u.packageURL = fakeURL.String()
|
||||
|
||||
require.NoError(t, u.prepare())
|
||||
require.NoError(t, u.prepare("AdGuardHome.exe"))
|
||||
|
||||
u.currentExeName = filepath.Join(wd, "AdGuardHome.exe")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user