2014-10-22 15:14:16 +00:00
|
|
|
package main
|
2014-11-13 10:55:51 +00:00
|
|
|
|
2014-10-22 15:14:16 +00:00
|
|
|
import "github.com/hlandau/degoutils/config"
|
2014-11-14 08:51:57 +00:00
|
|
|
import "github.com/hlandau/degoutils/service"
|
2014-10-22 15:14:16 +00:00
|
|
|
import "github.com/hlandau/ncdns/server"
|
2014-11-14 09:40:46 +00:00
|
|
|
import "path/filepath"
|
2014-10-22 15:14:16 +00:00
|
|
|
|
|
|
|
func main() {
|
2014-11-13 10:55:51 +00:00
|
|
|
cfg := server.ServerConfig{}
|
|
|
|
config := config.Configurator{
|
|
|
|
ProgramName: "ncdns",
|
2014-11-14 09:40:46 +00:00
|
|
|
ConfigFilePaths: []string{"$BIN/../etc/ncdns.conf", "/etc/ncdns/ncdns.conf"},
|
2014-11-13 10:55:51 +00:00
|
|
|
}
|
|
|
|
config.ParseFatal(&cfg)
|
2014-11-11 10:35:48 +00:00
|
|
|
|
2014-11-14 09:40:46 +00:00
|
|
|
// We use the configPath to resolve paths relative to the config file.
|
|
|
|
cfg.ConfigDir = filepath.Dir(config.ConfigFilePath())
|
|
|
|
|
2014-11-14 08:51:57 +00:00
|
|
|
service.Main(&service.Info{
|
2014-11-25 13:50:51 +00:00
|
|
|
Name: "ncdns",
|
|
|
|
Description: "Namecoin to DNS Daemon",
|
2014-11-15 08:52:14 +00:00
|
|
|
DefaultChroot: service.EmptyChrootPath,
|
2014-11-14 08:51:57 +00:00
|
|
|
RunFunc: func(smgr service.Manager) error {
|
|
|
|
s, err := server.NewServer(&cfg)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = s.Start()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2014-11-15 08:52:14 +00:00
|
|
|
err = smgr.DropPrivileges()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2014-11-14 08:51:57 +00:00
|
|
|
smgr.SetStarted()
|
2014-11-14 09:40:46 +00:00
|
|
|
smgr.SetStatus("ncdns: running ok")
|
|
|
|
|
2014-11-14 08:51:57 +00:00
|
|
|
<-smgr.StopChan()
|
|
|
|
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
})
|
2014-10-22 15:14:16 +00:00
|
|
|
}
|
2014-11-11 10:35:48 +00:00
|
|
|
|
|
|
|
// © 2014 Hugo Landau <hlandau@devever.net> GPLv3 or later
|