+ app: disable new version check and auto-update by command line switch
This commit is contained in:
parent
b9df476c5d
commit
f25639f1fc
|
@ -256,6 +256,12 @@ Response:
|
||||||
|
|
||||||
If `can_autoupdate` is true, then the server can automatically upgrade to a new version.
|
If `can_autoupdate` is true, then the server can automatically upgrade to a new version.
|
||||||
|
|
||||||
|
Response with empty body:
|
||||||
|
|
||||||
|
200 OK
|
||||||
|
|
||||||
|
It means that update check is disabled by user. UI should do nothing.
|
||||||
|
|
||||||
|
|
||||||
### Update command
|
### Update command
|
||||||
|
|
||||||
|
|
3
app.go
3
app.go
|
@ -79,6 +79,7 @@ func run(args options) {
|
||||||
log.Info("AdGuard Home is running as a service")
|
log.Info("AdGuard Home is running as a service")
|
||||||
}
|
}
|
||||||
config.runningAsService = args.runningAsService
|
config.runningAsService = args.runningAsService
|
||||||
|
config.disableUpdate = args.disableUpdate
|
||||||
|
|
||||||
config.firstRun = detectFirstRun()
|
config.firstRun = detectFirstRun()
|
||||||
if config.firstRun {
|
if config.firstRun {
|
||||||
|
@ -408,6 +409,7 @@ type options struct {
|
||||||
logFile string // Path to the log file. If empty, write to stdout. If "syslog", writes to syslog
|
logFile string // Path to the log file. If empty, write to stdout. If "syslog", writes to syslog
|
||||||
pidFile string // File name to save PID to
|
pidFile string // File name to save PID to
|
||||||
checkConfig bool // Check configuration and exit
|
checkConfig bool // Check configuration and exit
|
||||||
|
disableUpdate bool // If set, don't check for updates
|
||||||
|
|
||||||
// service control action (see service.ControlAction array + "status" command)
|
// service control action (see service.ControlAction array + "status" command)
|
||||||
serviceControlAction string
|
serviceControlAction string
|
||||||
|
@ -446,6 +448,7 @@ func loadOptions() options {
|
||||||
}, nil},
|
}, nil},
|
||||||
{"pidfile", "", "Path to a file where PID is stored", func(value string) { o.pidFile = value }, nil},
|
{"pidfile", "", "Path to a file where PID is stored", func(value string) { o.pidFile = value }, nil},
|
||||||
{"check-config", "", "Check configuration and exit", nil, func() { o.checkConfig = true }},
|
{"check-config", "", "Check configuration and exit", nil, func() { o.checkConfig = true }},
|
||||||
|
{"no-check-update", "", "Don't check for updates", nil, func() { o.disableUpdate = true }},
|
||||||
{"verbose", "v", "Enable verbose output", nil, func() { o.verbose = true }},
|
{"verbose", "v", "Enable verbose output", nil, func() { o.verbose = true }},
|
||||||
{"help", "", "Print this help", nil, func() {
|
{"help", "", "Print this help", nil, func() {
|
||||||
printHelp()
|
printHelp()
|
||||||
|
|
|
@ -39,6 +39,7 @@ type configuration struct {
|
||||||
firstRun bool // if set to true, don't run any services except HTTP web inteface, and serve only first-run html
|
firstRun bool // if set to true, don't run any services except HTTP web inteface, and serve only first-run html
|
||||||
// runningAsService flag is set to true when options are passed from the service runner
|
// runningAsService flag is set to true when options are passed from the service runner
|
||||||
runningAsService bool
|
runningAsService bool
|
||||||
|
disableUpdate bool // If set, don't check for updates
|
||||||
|
|
||||||
BindHost string `yaml:"bind_host"` // BindHost is the IP address of the HTTP server to bind to
|
BindHost string `yaml:"bind_host"` // BindHost is the IP address of the HTTP server to bind to
|
||||||
BindPort int `yaml:"bind_port"` // BindPort is the port the HTTP server
|
BindPort int `yaml:"bind_port"` // BindPort is the port the HTTP server
|
||||||
|
|
|
@ -52,6 +52,11 @@ func getVersionResp(data []byte) []byte {
|
||||||
func handleGetVersionJSON(w http.ResponseWriter, r *http.Request) {
|
func handleGetVersionJSON(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Tracef("%s %v", r.Method, r.URL)
|
log.Tracef("%s %v", r.Method, r.URL)
|
||||||
|
|
||||||
|
if config.disableUpdate {
|
||||||
|
log.Tracef("New app version check is disabled by user")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
controlLock.Lock()
|
controlLock.Lock()
|
||||||
cached := now.Sub(versionCheckLastTime) <= versionCheckPeriod && len(versionCheckJSON) != 0
|
cached := now.Sub(versionCheckLastTime) <= versionCheckPeriod && len(versionCheckJSON) != 0
|
||||||
|
|
Loading…
Reference in New Issue