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
|
||||
var ThisSession Session
|
||||
var MainConfig Config
|
||||
|
||||
const defaultConfigDir string = "default-config/"
|
||||
const configDir string = "config/"
|
||||
|
||||
|
@ -33,6 +34,7 @@ func loadConfig() Config {
|
|||
fmt.Println("Loading Custom Services…")
|
||||
customsvcfile := configDir + "services.yaml"
|
||||
unmarshalConfig(customsvcfile, &cfg)
|
||||
removeDisabledItems(&cfg)
|
||||
return cfg
|
||||
}
|
||||
|
||||
|
@ -44,12 +46,36 @@ func unmarshalConfig(file string, cfg *Config) {
|
|||
}
|
||||
err2 := yaml.Unmarshal(content, &cfg)
|
||||
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 {
|
||||
exists := false
|
||||
if _, err := os.Stat(file); err == nil {
|
||||
|
|
|
@ -1,50 +1,60 @@
|
|||
<clientConfig version="1.1">
|
||||
<emailProvider id="{{ index .Config.Domains 0 }}">
|
||||
{{ range .Config.Domains }}<domain>{{ . }}</domain>
|
||||
{{ end }}
|
||||
<displayName>{{ .Email }}</displayName>
|
||||
{{ with .Config.InMail }}
|
||||
<incomingServer type="{{ .Type | lower }}">
|
||||
<hostname>{{ .Server }}</hostname>
|
||||
<port>{{ .Port }}</port>
|
||||
<socketType>{{ .SocketType }}</socketType>
|
||||
<username>{{ . | parseUsername }}</username>
|
||||
<authentication>{{ .Authentication }}</authentication>
|
||||
</incomingServer>
|
||||
{{ end }}
|
||||
{{ with .Config.OutMail }}
|
||||
<outgoingServer type="{{ .Type | lower }}">
|
||||
<hostname>{{ .Server }}</hostname>
|
||||
<port>{{ .Port }}></port>
|
||||
<socketType>{{ .SocketType }}</socketType>
|
||||
<username>{{ . | parseUsername }}</username>
|
||||
<authentication>{{ .Authentication }}</authentication>
|
||||
</outgoingServer>
|
||||
{{ end }}
|
||||
{{ with .Config.AddressBook }}
|
||||
<addressBook type="{{ .Type | lower }}">
|
||||
<username>{{ . | parseUsername }}</username>
|
||||
<authentication>{{ .Authentication }}</authentication>
|
||||
<serverURL>{{ .Server }}</serverURL>
|
||||
</addressBook>
|
||||
<emailProvider id="{{ index .Config.Domains 0 }}">
|
||||
{{ range .Config.Domains }}<domain>{{ . }}</domain>
|
||||
{{ end }}
|
||||
<displayName>{{ .Email }}</displayName>
|
||||
{{ with .Config.InMail }}
|
||||
{{ if .Enabled }}
|
||||
<incomingServer type="{{ .Type | lower }}">
|
||||
<hostname>{{ .Server }}</hostname>
|
||||
<port>{{ .Port }}</port>
|
||||
<socketType>{{ .SocketType }}</socketType>
|
||||
<username>{{ . | parseUsername }}</username>
|
||||
<authentication>{{ .Authentication }}</authentication>
|
||||
</incomingServer>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ with .Config.OutMail }}
|
||||
{{ if .Enabled }}
|
||||
<outgoingServer type="{{ .Type | lower }}">
|
||||
<hostname>{{ .Server }}</hostname>
|
||||
<port>{{ .Port }}></port>
|
||||
<socketType>{{ .SocketType }}</socketType>
|
||||
<username>{{ . | parseUsername }}</username>
|
||||
<authentication>{{ .Authentication }}</authentication>
|
||||
</outgoingServer>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ with .Config.AddressBook }}
|
||||
{{ if .Enabled }}
|
||||
<addressBook type="{{ .Type | lower }}">
|
||||
<username>{{ . | parseUsername }}</username>
|
||||
<authentication>{{ .Authentication }}</authentication>
|
||||
<serverURL>{{ .Server }}</serverURL>
|
||||
</addressBook>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ with .Config.Calendar }}
|
||||
<calendar type="{{ .Type | lower }}">
|
||||
<username>{{ . | parseUsername }}</username>
|
||||
<authentication>{{ .Authentication }}</authentication>
|
||||
<serverURL>{{ .Server }}</serverURL>
|
||||
</calendar>
|
||||
{{ if .Enabled }}
|
||||
<calendar type="{{ .Type | lower }}">
|
||||
<username>{{ . | parseUsername }}</username>
|
||||
<authentication>{{ .Authentication }}</authentication>
|
||||
<serverURL>{{ .Server }}</serverURL>
|
||||
</calendar>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ with .Config.WebMail }}
|
||||
<webMail>
|
||||
<loginPage url="{{ .Server }}" />
|
||||
<loginPageInfo url="{{ .Server }}">
|
||||
<username>{{ . | parseUsername }}</username>
|
||||
<usernameField id="{{ .UsernameDivID }}" name="{{ .UsernameDivID }}" />
|
||||
<passwordField name="{{ .PasswordDivName }}" />
|
||||
<loginButton id="{{ .SubmitButtonID }}" name="{{ .SubmitButtonName }}"/>
|
||||
</loginPageInfo>
|
||||
</webMail>
|
||||
{{ if .Enabled }}
|
||||
<webMail>
|
||||
<loginPage url="{{ .Server }}" />
|
||||
<loginPageInfo url="{{ .Server }}">
|
||||
<username>{{ . | parseUsername }}</username>
|
||||
<usernameField id="{{ .UsernameDivID }}" name="{{ .UsernameDivID }}" />
|
||||
<passwordField name="{{ .PasswordDivName }}" />
|
||||
<loginButton id="{{ .SubmitButtonID }}" name="{{ .SubmitButtonName }}"/>
|
||||
</loginPageInfo>
|
||||
</webMail>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</emailProvider>
|
||||
</clientConfig>
|
||||
|
|
|
@ -5,30 +5,34 @@
|
|||
<AccountType>email</AccountType>
|
||||
<Action>settings</Action>
|
||||
{{ with .Config.InMail }}
|
||||
<Protocol>
|
||||
<Type>{{ .Type }}</Type>
|
||||
<Server>{{ .Server }}</Server>
|
||||
<Port>{{ .Port }}</Port>
|
||||
<DomainRequired>{{ .UsernameIsFQDN | onoff }}</DomainRequired>
|
||||
<LoginName>{{ . | parseUsername }}</LoginName>
|
||||
<SPA>{{ .SPA | onoff }}</SPA>
|
||||
<SSL>{{ if eq .SocketType "SSL" }}on{{ else }}off{{ end }}</SSL>
|
||||
<AuthRequired>{{ not .NoAuthRequired | onoff }}</AuthRequired>
|
||||
</Protocol>
|
||||
{{ if .Enabled }}
|
||||
<Protocol>
|
||||
<Type>{{ .Type }}</Type>
|
||||
<Server>{{ .Server }}</Server>
|
||||
<Port>{{ .Port }}</Port>
|
||||
<DomainRequired>{{ .UsernameIsFQDN | onoff }}</DomainRequired>
|
||||
<LoginName>{{ . | parseUsername }}</LoginName>
|
||||
<SPA>{{ .SPA | onoff }}</SPA>
|
||||
<SSL>{{ if eq .SocketType "SSL" }}on{{ else }}off{{ end }}</SSL>
|
||||
<AuthRequired>{{ not .NoAuthRequired | onoff }}</AuthRequired>
|
||||
</Protocol>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ with .Config.OutMail }}
|
||||
<Protocol>
|
||||
<Type>{{ .Type }}</Type>
|
||||
<Server>{{ .Server }}</Server>
|
||||
<Port>{{ .Port }}</Port>
|
||||
<DomainRequired>{{ .UsernameIsFQDN | onoff }}</DomainRequired>
|
||||
<LoginName>{{ . | parseUsername }}</LoginName>
|
||||
<SPA>{{ .SPA | onoff }}</SPA>
|
||||
<Encryption>{{ .SocketType }}</Encryption>
|
||||
<AuthRequired>{{ not .NoAuthRequired | onoff }}</AuthRequired>
|
||||
<UsePOPAuth>{{ .POPAuth | onoff }}</UsePOPAuth>
|
||||
<SMTPLast>{{ .SMTPLast | onoff }}</SMTPLast>
|
||||
</Protocol>
|
||||
{{ if .Enabled }}
|
||||
<Protocol>
|
||||
<Type>{{ .Type }}</Type>
|
||||
<Server>{{ .Server }}</Server>
|
||||
<Port>{{ .Port }}</Port>
|
||||
<DomainRequired>{{ .UsernameIsFQDN | onoff }}</DomainRequired>
|
||||
<LoginName>{{ . | parseUsername }}</LoginName>
|
||||
<SPA>{{ .SPA | onoff }}</SPA>
|
||||
<Encryption>{{ .SocketType }}</Encryption>
|
||||
<AuthRequired>{{ not .NoAuthRequired | onoff }}</AuthRequired>
|
||||
<UsePOPAuth>{{ .POPAuth | onoff }}</UsePOPAuth>
|
||||
<SMTPLast>{{ .SMTPLast | onoff }}</SMTPLast>
|
||||
</Protocol>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</Account>
|
||||
</Response>
|
||||
|
|
|
@ -81,7 +81,7 @@ func OurConfig() string {
|
|||
}
|
||||
func parseUsername(svc Service) string {
|
||||
if email == "" {
|
||||
return "<!-- not provided -->"
|
||||
return "not-provided"
|
||||
}
|
||||
if svc.UsernameIsFQDN && !svc.RequireLocalDomain{
|
||||
return email
|
||||
|
|
Loading…
Reference in a new issue