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"
|
2014-02-25 20:11:34 +01:00
|
|
|
"os"
|
2014-03-02 06:51:52 +01:00
|
|
|
"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")
|
2014-02-25 20:11:34 +01:00
|
|
|
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 != "" {
|
2014-03-02 00:10:04 +01:00
|
|
|
encoded, err := irc.GenerateEncodedPassword(*passwd)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(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 {
|
|
|
|
log.Fatal(err)
|
2014-02-25 20:11:34 +01:00
|
|
|
}
|
2014-03-02 06:51:52 +01:00
|
|
|
err = os.Chdir(filepath.Dir(*conf))
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2014-02-25 20:11:34 +01:00
|
|
|
|
|
|
|
if *initdb {
|
2014-03-02 20:41:24 +01:00
|
|
|
irc.InitDB(config.Server.Database)
|
|
|
|
log.Println("database initialized: " + config.Server.Database)
|
2014-02-09 16:53:42 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2014-02-25 20:11:34 +01:00
|
|
|
// TODO move to data structures
|
2014-03-01 23:34:51 +01:00
|
|
|
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
|
|
|
}
|