freeswitch container: use x-pre-process includes for static configs
All checks were successful
/ build-freeswitch (push) Successful in 20m31s
All checks were successful
/ build-freeswitch (push) Successful in 20m31s
This commit is contained in:
parent
e053d68597
commit
b4fd4e7d68
1 changed files with 2 additions and 31 deletions
|
@ -4,11 +4,8 @@ import (
|
||||||
"embed"
|
"embed"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"io/fs"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/kelseyhightower/envconfig"
|
"github.com/kelseyhightower/envconfig"
|
||||||
|
@ -21,7 +18,6 @@ type Options struct {
|
||||||
LogLevel string `envconfig:"LOG_LEVEL" default:"info"`
|
LogLevel string `envconfig:"LOG_LEVEL" default:"info"`
|
||||||
Gateway Gateway `envconfig:"GATEWAY"`
|
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"`
|
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 {
|
type Gateway struct {
|
||||||
|
@ -147,7 +143,7 @@ func main() {
|
||||||
|
|
||||||
fmt.Println("</section>")
|
fmt.Println("</section>")
|
||||||
|
|
||||||
staticConfigDirectories, err := os.ReadDir(options.StaticXMLDir)
|
staticConfigDirectories, err := os.ReadDir("/usr/local/freeswitch/conf")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, os.ErrNotExist) {
|
if errors.Is(err, os.ErrNotExist) {
|
||||||
return
|
return
|
||||||
|
@ -160,32 +156,7 @@ func main() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fmt.Printf("<section name=\"%s\">\n", entry.Name())
|
fmt.Printf("<section name=\"%s\">\n", entry.Name())
|
||||||
|
fmt.Printf("<X-PRE-PROCESS cmd=\"include\" data=\"%s/*.xml\" />\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("<!-- %s -->\n", path)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("<!-- ERROR: %v -->", 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("</section>")
|
fmt.Println("</section>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue