diff --git a/containers/freeswitch/dynamic-xmlconfig/autoload_configs/modules.conf.xml b/containers/freeswitch/dynamic-xmlconfig/autoload_configs/modules.conf.xml index 7d577c4..edc9b6e 100644 --- a/containers/freeswitch/dynamic-xmlconfig/autoload_configs/modules.conf.xml +++ b/containers/freeswitch/dynamic-xmlconfig/autoload_configs/modules.conf.xml @@ -1,6 +1,6 @@ - {{ $_, $module := range .Modules }}{{ end }} + {{ range $_, $module := .Modules }}{{ end }} diff --git a/containers/freeswitch/dynamic-xmlconfig/main.go b/containers/freeswitch/dynamic-xmlconfig/main.go index 44efb8f..feab103 100644 --- a/containers/freeswitch/dynamic-xmlconfig/main.go +++ b/containers/freeswitch/dynamic-xmlconfig/main.go @@ -2,9 +2,13 @@ package main import ( "embed" + "errors" "fmt" + "io" + "io/fs" "net/url" "os" + "path/filepath" "text/template" "github.com/kelseyhightower/envconfig" @@ -17,6 +21,7 @@ type Options struct { LogLevel string `envconfig:"LOG_LEVEL" default:"info"` Gateway Gateway `envconfig:"GATEWAY"` Modules []string `envconfig:"MODULES" default:"mod_event_socket,mod_sofia,mod_db,mod_dialplan_xml,mod_g723_1,mod_g729,mod_amr,mod_b64,mod_opus,mod_av,mod_sndfile,mod_native_file,mod_png,mod_local_stream,mod_tone_stream,mod_lua,mod_say_en"` + StaticXMLDir string `envconfig:"STATIC_XML_DIR" default:"/config"` } type Gateway struct { @@ -141,6 +146,48 @@ func main() { } fmt.Println("") + + staticConfigDirectories, err := os.ReadDir(options.StaticXMLDir) + if err != nil { + if errors.Is(err, os.ErrNotExist) { + return + } + panic(err) + } + + for _, entry := range staticConfigDirectories { + if !entry.IsDir() { + continue + } + fmt.Printf("
\n", entry.Name()) + + filepath.WalkDir(filepath.Join(options.StaticXMLDir, entry.Name()), func(path string, d fs.DirEntry, err error) error { + if d.IsDir() { + return nil + } + + fmt.Printf("\n", path) + if err != nil { + fmt.Printf("", err) + return err + } + + f, err := os.Open(path) + if err != nil { + panic(err) + } + defer f.Close() + + data, err := io.ReadAll(f) + if err != nil { + panic(err) + } + fmt.Println(string(data)) + + return nil + }) + fmt.Println("
") + } } func (g *Gateway) Decode(value string) error {