mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-06 17:29:15 +08:00
Merge pull request #2133 from gravitl/refactor_auto_update
Add host level auto update setting with default true
This commit is contained in:
@@ -19,6 +19,7 @@ services:
|
||||
COREDNS_ADDR: "SERVER_PUBLIC_IP"
|
||||
DNS_MODE: "on"
|
||||
SERVER_HTTP_HOST: "api.NETMAKER_BASE_DOMAIN"
|
||||
NETCLIENT_AUTO_UPDATE: "enabled"
|
||||
API_PORT: "8081"
|
||||
MASTER_KEY: "REPLACE_MASTER_KEY"
|
||||
CORS_ALLOWED_ORIGIN: "*"
|
||||
|
@@ -17,6 +17,7 @@ services:
|
||||
COREDNS_ADDR: "SERVER_PUBLIC_IP"
|
||||
DNS_MODE: "on"
|
||||
SERVER_HTTP_HOST: "api.NETMAKER_BASE_DOMAIN"
|
||||
NETCLIENT_AUTO_UPDATE: "enabled"
|
||||
API_PORT: "8081"
|
||||
MASTER_KEY: "REPLACE_MASTER_KEY"
|
||||
CORS_ALLOWED_ORIGIN: "*"
|
||||
|
@@ -14,6 +14,7 @@ services:
|
||||
SERVER_NAME: "NETMAKER_BASE_DOMAIN" # The base domain of netmaker
|
||||
SERVER_HOST: "SERVER_PUBLIC_IP" # Set to public IP of machine.
|
||||
SERVER_HTTP_HOST: "api.NETMAKER_BASE_DOMAIN" # Overrides SERVER_HOST if set. Useful for making HTTP available via different interfaces/networks.
|
||||
NETCLIENT_AUTO_UPDATE: "enabled" # Enable auto update of netclient ? ENUM:- enabled,disabled | default: enabled
|
||||
SERVER_API_CONN_STRING: "api.NETMAKER_BASE_DOMAIN:443"
|
||||
COREDNS_ADDR: "SERVER_PUBLIC_IP" # Address of the CoreDNS server. Defaults to SERVER_HOST
|
||||
DNS_MODE: "on" # Enables DNS Mode, meaning all nodes will set hosts file for private dns settings.
|
||||
|
@@ -17,6 +17,7 @@ services:
|
||||
COREDNS_ADDR: "SERVER_PUBLIC_IP"
|
||||
DNS_MODE: "on"
|
||||
SERVER_HTTP_HOST: "api.NETMAKER_BASE_DOMAIN"
|
||||
NETCLIENT_AUTO_UPDATE: "enabled"
|
||||
API_PORT: "8081"
|
||||
MASTER_KEY: "REPLACE_MASTER_KEY"
|
||||
CORS_ALLOWED_ORIGIN: "*"
|
||||
|
@@ -40,6 +40,7 @@ type ServerConfig struct {
|
||||
ServerBrokerEndpoint string `yaml:"serverbrokerendpoint"`
|
||||
BrokerType string `yaml:"brokertype"`
|
||||
EmqxRestEndpoint string `yaml:"emqxrestendpoint"`
|
||||
NetclientAutoUpdate string `yaml:"netclientautoupdate"`
|
||||
MasterKey string `yaml:"masterkey"`
|
||||
DNSKey string `yaml:"dnskey"`
|
||||
AllowedOrigin string `yaml:"allowedorigin"`
|
||||
|
@@ -97,6 +97,7 @@ func CreateHost(h *models.Host) error {
|
||||
return err
|
||||
}
|
||||
h.HostPass = string(hash)
|
||||
h.AutoUpdate = servercfg.AutoUpdateEnabled()
|
||||
// if another server has already updated proxyenabled, leave it alone
|
||||
if !h.ProxyEnabledSet {
|
||||
log.Println("checking default proxy", servercfg.GetServerConfig().DefaultProxyMode)
|
||||
|
@@ -47,6 +47,7 @@ type Host struct {
|
||||
Version string `json:"version" yaml:"version"`
|
||||
IPForwarding bool `json:"ipforwarding" yaml:"ipforwarding"`
|
||||
DaemonInstalled bool `json:"daemoninstalled" yaml:"daemoninstalled"`
|
||||
AutoUpdate bool `json:"autoupdate" yaml:"autoupdate"`
|
||||
HostPass string `json:"hostpass" yaml:"hostpass"`
|
||||
Name string `json:"name" yaml:"name"`
|
||||
OS string `json:"os" yaml:"os"`
|
||||
|
@@ -46,6 +46,11 @@ func GetServerConfig() config.ServerConfig {
|
||||
cfg.StunPort = GetStunPort()
|
||||
cfg.BrokerType = GetBrokerType()
|
||||
cfg.EmqxRestEndpoint = GetEmqxRestEndpoint()
|
||||
if AutoUpdateEnabled() {
|
||||
cfg.NetclientAutoUpdate = "enabled"
|
||||
} else {
|
||||
cfg.NetclientAutoUpdate = "disabled"
|
||||
}
|
||||
if IsRestBackend() {
|
||||
cfg.RestBackend = "on"
|
||||
}
|
||||
@@ -382,6 +387,17 @@ func GetVerbosity() int32 {
|
||||
return int32(verbosity)
|
||||
}
|
||||
|
||||
// AutoUpdateEnabled returns a boolean indicating whether netclient auto update is enabled or disabled
|
||||
// default is enabled
|
||||
func AutoUpdateEnabled() bool {
|
||||
if os.Getenv("NETCLIENT_AUTO_UPDATE") == "disabled" {
|
||||
return false
|
||||
} else if config.Config.Server.NetclientAutoUpdate == "disabled" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// IsDNSMode - should it run with DNS
|
||||
func IsDNSMode() bool {
|
||||
isdns := true
|
||||
|
Reference in New Issue
Block a user