mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-25 14:35:48 +03:00
Auto-update interface
This commit is contained in:
parent
62ccd3fb41
commit
1bb183c2aa
3 changed files with 46 additions and 0 deletions
|
@ -244,6 +244,8 @@ func getUpdateInfo(jsonData []byte) (*updateInfo, error) {
|
|||
if runtime.GOOS == "windows" {
|
||||
binName = "AdGuardHome.exe"
|
||||
}
|
||||
|
||||
// TODO: This is a mistake, work dir can be different
|
||||
u.curBinName = filepath.Join(workDir, binName)
|
||||
if !util.FileExists(u.curBinName) {
|
||||
return nil, fmt.Errorf("executable file %s doesn't exist", u.curBinName)
|
||||
|
|
13
update/check.go
Normal file
13
update/check.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
package update
|
||||
|
||||
type VersionInfo struct {
|
||||
NewVersion string
|
||||
Announcement string
|
||||
AnnouncementURL string
|
||||
SelfUpdateMinVersion string
|
||||
CanAutoUpdate bool
|
||||
}
|
||||
|
||||
func (u *Updater) GetVersionResponse() (VersionInfo, error) {
|
||||
return VersionInfo{}, nil
|
||||
}
|
31
update/updater.go
Normal file
31
update/updater.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package update
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
type Updater struct {
|
||||
DisableUpdate bool
|
||||
|
||||
currentBinary string // current binary executable
|
||||
workDir string // updater work dir (where backup/upd dirs will be created)
|
||||
}
|
||||
|
||||
// NewUpdater - creates a new instance of the Updater
|
||||
func NewUpdater(workDir string) *Updater {
|
||||
return &Updater{
|
||||
currentBinary: filepath.Base(os.Args[0]),
|
||||
workDir: workDir,
|
||||
}
|
||||
}
|
||||
|
||||
// DoUpdate - conducts the auto-update
|
||||
// 1. Downloads the update file
|
||||
// 2. Unpacks it and checks the contents
|
||||
// 3. Backups the current version and configuration
|
||||
// 4. Replaces the old files
|
||||
// 5. Restarts the service
|
||||
func (u *Updater) DoUpdate() error {
|
||||
return nil
|
||||
}
|
Loading…
Reference in a new issue