mirror of
https://github.com/safing/portmaster
synced 2025-04-24 12:59:10 +00:00
Add support for --disable-software-updates to disable software updates by cli-flag and also prevents chaning their values
This commit is contained in:
parent
3c0a362bff
commit
35ecda9166
2 changed files with 43 additions and 3 deletions
|
@ -2,6 +2,7 @@ package updates
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/tevino/abool"
|
||||
|
||||
|
@ -29,6 +30,9 @@ var (
|
|||
)
|
||||
|
||||
func registerConfig() error {
|
||||
releaseLevelSet := abool.New()
|
||||
softwareUpdateSet := abool.New()
|
||||
|
||||
err := config.Register(&config.Option{
|
||||
Name: "Release Channel",
|
||||
Key: helper.ReleaseChannelKey,
|
||||
|
@ -38,6 +42,23 @@ func registerConfig() error {
|
|||
ReleaseLevel: config.ReleaseLevelStable,
|
||||
RequiresRestart: true,
|
||||
DefaultValue: helper.ReleaseChannelStable,
|
||||
// TODO(ppacher): it would actually be better to hide the option from the UI
|
||||
ValidationFunc: func(value interface{}) error {
|
||||
if releaseLevelSet.SetToIf(false, true) || releaseChannel == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
return errors.New("invalid value")
|
||||
}
|
||||
|
||||
if softwareUpdatesDisabledByFlag && releaseChannel() != v {
|
||||
return errors.New("automatic software updates are not supported by the choosen installation method")
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
PossibleValues: []config.PossibleValue{
|
||||
{
|
||||
Name: "Stable",
|
||||
|
@ -78,7 +99,24 @@ func registerConfig() error {
|
|||
ExpertiseLevel: config.ExpertiseLevelExpert,
|
||||
ReleaseLevel: config.ReleaseLevelStable,
|
||||
RequiresRestart: false,
|
||||
DefaultValue: true,
|
||||
// TODO(ppacher): it would be better to actually hide the whole setting from the UI.
|
||||
DefaultValue: !softwareUpdatesDisabledByFlag,
|
||||
ValidationFunc: func(value interface{}) error {
|
||||
if softwareUpdateSet.SetToIf(false, true) || enableSoftwareUpdates == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
v, ok := value.(bool)
|
||||
if !ok {
|
||||
return errors.New("invalid value")
|
||||
}
|
||||
|
||||
if softwareUpdatesDisabledByFlag && v {
|
||||
return errors.New("automatic software updates are not supported by the choosen installation method")
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
Annotations: config.Annotations{
|
||||
config.DisplayOrderAnnotation: -12,
|
||||
config.CategoryAnnotation: "Updates",
|
||||
|
|
|
@ -46,8 +46,9 @@ var (
|
|||
module *modules.Module
|
||||
registry *updater.ResourceRegistry
|
||||
|
||||
userAgentFromFlag string
|
||||
updateServerFromFlag string
|
||||
userAgentFromFlag string
|
||||
updateServerFromFlag string
|
||||
softwareUpdatesDisabledByFlag bool
|
||||
|
||||
updateTask *modules.Task
|
||||
updateASAP bool
|
||||
|
@ -86,6 +87,7 @@ func init() {
|
|||
|
||||
flag.StringVar(&updateServerFromFlag, "update-server", "", "set an alternative update server (full URL)")
|
||||
flag.StringVar(&userAgentFromFlag, "update-agent", "", "set an alternative user agent for requests to the update server")
|
||||
flag.BoolVar(&softwareUpdatesDisabledByFlag, "disable-software-updates", false, "Disable automatic software updates")
|
||||
}
|
||||
|
||||
func prep() error {
|
||||
|
|
Loading…
Add table
Reference in a new issue