Auto-update interface
This commit is contained in:
parent
62ccd3fb41
commit
1bb183c2aa
|
@ -244,6 +244,8 @@ func getUpdateInfo(jsonData []byte) (*updateInfo, error) {
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
binName = "AdGuardHome.exe"
|
binName = "AdGuardHome.exe"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: This is a mistake, work dir can be different
|
||||||
u.curBinName = filepath.Join(workDir, binName)
|
u.curBinName = filepath.Join(workDir, binName)
|
||||||
if !util.FileExists(u.curBinName) {
|
if !util.FileExists(u.curBinName) {
|
||||||
return nil, fmt.Errorf("executable file %s doesn't exist", u.curBinName)
|
return nil, fmt.Errorf("executable file %s doesn't exist", u.curBinName)
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
|
@ -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 New Issue