re-enabled enabling/disabled services
This commit is contained in:
parent
50c8d3baf2
commit
7f78103ce5
4 changed files with 107 additions and 67 deletions
|
@ -12,6 +12,7 @@ import (
|
||||||
// Global variables
|
// Global variables
|
||||||
var ThisSession Session
|
var ThisSession Session
|
||||||
var MainConfig Config
|
var MainConfig Config
|
||||||
|
|
||||||
const defaultConfigDir string = "default-config/"
|
const defaultConfigDir string = "default-config/"
|
||||||
const configDir string = "config/"
|
const configDir string = "config/"
|
||||||
|
|
||||||
|
@ -33,6 +34,7 @@ func loadConfig() Config {
|
||||||
fmt.Println("Loading Custom Services…")
|
fmt.Println("Loading Custom Services…")
|
||||||
customsvcfile := configDir + "services.yaml"
|
customsvcfile := configDir + "services.yaml"
|
||||||
unmarshalConfig(customsvcfile, &cfg)
|
unmarshalConfig(customsvcfile, &cfg)
|
||||||
|
removeDisabledItems(&cfg)
|
||||||
return cfg
|
return cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,12 +46,36 @@ func unmarshalConfig(file string, cfg *Config) {
|
||||||
}
|
}
|
||||||
err2 := yaml.Unmarshal(content, &cfg)
|
err2 := yaml.Unmarshal(content, &cfg)
|
||||||
if err2 != nil {
|
if err2 != nil {
|
||||||
fmt.Println("Error unmarshalling config :", file, " : ", err2)
|
fmt.Println("Error unmarshaling config :", file, " : ", err2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func removeDisabledItems(cfg *Config) {
|
||||||
|
// Rework this, not pretty
|
||||||
|
if !cfg.InMail.Enabled {
|
||||||
|
cfg.InMail = Service{}
|
||||||
|
}
|
||||||
|
if !cfg.OutMail.Enabled {
|
||||||
|
cfg.OutMail = Service{}
|
||||||
|
}
|
||||||
|
if !cfg.Calendar.Enabled {
|
||||||
|
cfg.Calendar = Service{}
|
||||||
|
}
|
||||||
|
if !cfg.AddressBook.Enabled {
|
||||||
|
cfg.AddressBook = Service{}
|
||||||
|
}
|
||||||
|
if !cfg.WebMail.Enabled {
|
||||||
|
cfg.WebMail = Service{}
|
||||||
|
}
|
||||||
|
new_svcs := []Service{}
|
||||||
|
for _,svc := range cfg.OtherServices {
|
||||||
|
if svc.Enabled {
|
||||||
|
new_svcs = append(new_svcs,svc)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cfg.OtherServices = new_svcs
|
||||||
|
}
|
||||||
func FileExists(file string) bool {
|
func FileExists(file string) bool {
|
||||||
exists := false
|
exists := false
|
||||||
if _, err := os.Stat(file); err == nil {
|
if _, err := os.Stat(file); err == nil {
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<displayName>{{ .Email }}</displayName>
|
<displayName>{{ .Email }}</displayName>
|
||||||
{{ with .Config.InMail }}
|
{{ with .Config.InMail }}
|
||||||
|
{{ if .Enabled }}
|
||||||
<incomingServer type="{{ .Type | lower }}">
|
<incomingServer type="{{ .Type | lower }}">
|
||||||
<hostname>{{ .Server }}</hostname>
|
<hostname>{{ .Server }}</hostname>
|
||||||
<port>{{ .Port }}</port>
|
<port>{{ .Port }}</port>
|
||||||
|
@ -12,7 +13,9 @@
|
||||||
<authentication>{{ .Authentication }}</authentication>
|
<authentication>{{ .Authentication }}</authentication>
|
||||||
</incomingServer>
|
</incomingServer>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
{{ with .Config.OutMail }}
|
{{ with .Config.OutMail }}
|
||||||
|
{{ if .Enabled }}
|
||||||
<outgoingServer type="{{ .Type | lower }}">
|
<outgoingServer type="{{ .Type | lower }}">
|
||||||
<hostname>{{ .Server }}</hostname>
|
<hostname>{{ .Server }}</hostname>
|
||||||
<port>{{ .Port }}></port>
|
<port>{{ .Port }}></port>
|
||||||
|
@ -21,21 +24,27 @@
|
||||||
<authentication>{{ .Authentication }}</authentication>
|
<authentication>{{ .Authentication }}</authentication>
|
||||||
</outgoingServer>
|
</outgoingServer>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
{{ with .Config.AddressBook }}
|
{{ with .Config.AddressBook }}
|
||||||
|
{{ if .Enabled }}
|
||||||
<addressBook type="{{ .Type | lower }}">
|
<addressBook type="{{ .Type | lower }}">
|
||||||
<username>{{ . | parseUsername }}</username>
|
<username>{{ . | parseUsername }}</username>
|
||||||
<authentication>{{ .Authentication }}</authentication>
|
<authentication>{{ .Authentication }}</authentication>
|
||||||
<serverURL>{{ .Server }}</serverURL>
|
<serverURL>{{ .Server }}</serverURL>
|
||||||
</addressBook>
|
</addressBook>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
{{ with .Config.Calendar }}
|
{{ with .Config.Calendar }}
|
||||||
|
{{ if .Enabled }}
|
||||||
<calendar type="{{ .Type | lower }}">
|
<calendar type="{{ .Type | lower }}">
|
||||||
<username>{{ . | parseUsername }}</username>
|
<username>{{ . | parseUsername }}</username>
|
||||||
<authentication>{{ .Authentication }}</authentication>
|
<authentication>{{ .Authentication }}</authentication>
|
||||||
<serverURL>{{ .Server }}</serverURL>
|
<serverURL>{{ .Server }}</serverURL>
|
||||||
</calendar>
|
</calendar>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
{{ with .Config.WebMail }}
|
{{ with .Config.WebMail }}
|
||||||
|
{{ if .Enabled }}
|
||||||
<webMail>
|
<webMail>
|
||||||
<loginPage url="{{ .Server }}" />
|
<loginPage url="{{ .Server }}" />
|
||||||
<loginPageInfo url="{{ .Server }}">
|
<loginPageInfo url="{{ .Server }}">
|
||||||
|
@ -46,5 +55,6 @@
|
||||||
</loginPageInfo>
|
</loginPageInfo>
|
||||||
</webMail>
|
</webMail>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
</emailProvider>
|
</emailProvider>
|
||||||
</clientConfig>
|
</clientConfig>
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<AccountType>email</AccountType>
|
<AccountType>email</AccountType>
|
||||||
<Action>settings</Action>
|
<Action>settings</Action>
|
||||||
{{ with .Config.InMail }}
|
{{ with .Config.InMail }}
|
||||||
|
{{ if .Enabled }}
|
||||||
<Protocol>
|
<Protocol>
|
||||||
<Type>{{ .Type }}</Type>
|
<Type>{{ .Type }}</Type>
|
||||||
<Server>{{ .Server }}</Server>
|
<Server>{{ .Server }}</Server>
|
||||||
|
@ -16,7 +17,9 @@
|
||||||
<AuthRequired>{{ not .NoAuthRequired | onoff }}</AuthRequired>
|
<AuthRequired>{{ not .NoAuthRequired | onoff }}</AuthRequired>
|
||||||
</Protocol>
|
</Protocol>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
{{ with .Config.OutMail }}
|
{{ with .Config.OutMail }}
|
||||||
|
{{ if .Enabled }}
|
||||||
<Protocol>
|
<Protocol>
|
||||||
<Type>{{ .Type }}</Type>
|
<Type>{{ .Type }}</Type>
|
||||||
<Server>{{ .Server }}</Server>
|
<Server>{{ .Server }}</Server>
|
||||||
|
@ -30,6 +33,7 @@
|
||||||
<SMTPLast>{{ .SMTPLast | onoff }}</SMTPLast>
|
<SMTPLast>{{ .SMTPLast | onoff }}</SMTPLast>
|
||||||
</Protocol>
|
</Protocol>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
</Account>
|
</Account>
|
||||||
</Response>
|
</Response>
|
||||||
</Autodiscover>
|
</Autodiscover>
|
||||||
|
|
|
@ -81,7 +81,7 @@ func OurConfig() string {
|
||||||
}
|
}
|
||||||
func parseUsername(svc Service) string {
|
func parseUsername(svc Service) string {
|
||||||
if email == "" {
|
if email == "" {
|
||||||
return "<!-- not provided -->"
|
return "not-provided"
|
||||||
}
|
}
|
||||||
if svc.UsernameIsFQDN && !svc.RequireLocalDomain{
|
if svc.UsernameIsFQDN && !svc.RequireLocalDomain{
|
||||||
return email
|
return email
|
||||||
|
|
Loading…
Reference in a new issue