freifunkmanager/config/main.go

46 lines
992 B
Go
Raw Normal View History

2017-05-06 14:37:24 +02:00
package config
import (
"io/ioutil"
"github.com/BurntSushi/toml"
2017-05-29 22:55:38 +02:00
"github.com/genofire/golang-lib/log"
2017-05-06 14:37:24 +02:00
)
//config file of this daemon (for more the config_example.conf in git repository)
type Config struct {
2017-05-07 03:37:30 +02:00
// prevent crashes
StatePath string `toml:"state_path"`
2017-05-06 14:37:24 +02:00
// address on which the api and static content webserver runs
WebserverBind string `toml:"webserver_bind"`
// path to deliver static content
Webroot string `toml:"webroot"`
// SSH private key
SSHPrivateKey string `toml:"ssh_key"`
SSHInterface string `toml:"ssh_interface"`
// yanic socket
Yanic struct {
Enable bool `toml:"enable"`
Type string `toml:"type"`
Address string `toml:"address"`
} `toml:"yanic"`
2017-05-06 14:37:24 +02:00
}
//reads a config model from path of a yml file
func ReadConfigFile(path string) *Config {
config := &Config{}
file, err := ioutil.ReadFile(path)
if err != nil {
log.Log.Panic(err)
}
if err := toml.Unmarshal(file, config); err != nil {
log.Log.Panic(err)
}
return config
}