3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-10 22:19:31 +01:00
ergo/ergonomadic.go

50 lines
1.0 KiB
Go
Raw Normal View History

2014-02-08 22:18:11 +01:00
package main
import (
2014-02-24 07:21:39 +01:00
"flag"
"fmt"
2014-02-08 22:18:11 +01:00
"github.com/jlatt/ergonomadic/irc"
2014-02-09 16:53:42 +01:00
"log"
"os"
"path/filepath"
2014-02-08 22:18:11 +01:00
)
func main() {
2014-03-06 08:51:32 +01:00
conf := flag.String("conf", "ergonomadic.conf", "ergonomadic config file")
initdb := flag.Bool("initdb", false, "initialize database")
2014-02-24 07:21:39 +01:00
passwd := flag.String("genpasswd", "", "bcrypt a password")
flag.Parse()
if *passwd != "" {
encoded, err := irc.GenerateEncodedPassword(*passwd)
if err != nil {
2014-03-06 08:07:55 +01:00
log.Fatal("encoding error: ", err)
}
fmt.Println(encoded)
2014-02-24 07:21:39 +01:00
return
}
config, err := irc.LoadConfig(*conf)
2014-02-09 16:53:42 +01:00
if err != nil {
2014-03-06 08:07:55 +01:00
log.Fatal("error loading config: ", err)
}
err = os.Chdir(filepath.Dir(*conf))
if err != nil {
2014-03-06 08:07:55 +01:00
log.Fatal("chdir error: ", err)
}
if *initdb {
irc.InitDB(config.Server.Database)
log.Println("database initialized: " + config.Server.Database)
2014-02-09 16:53:42 +01:00
return
}
// TODO move to data structures
irc.DEBUG_NET = config.Debug.Net
irc.DEBUG_CLIENT = config.Debug.Client
irc.DEBUG_CHANNEL = config.Debug.Channel
irc.DEBUG_SERVER = config.Debug.Server
2014-02-09 16:53:42 +01:00
2014-02-24 04:13:45 +01:00
irc.NewServer(config).Run()
2014-02-08 22:18:11 +01:00
}