3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 11:59:40 +01:00
ergo/oragono.go

64 lines
1.7 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
"fmt"
2014-02-09 16:53:42 +01:00
"log"
"syscall"
2014-03-13 02:57:00 +01:00
"github.com/DanielOaks/oragono/irc"
"github.com/docopt/docopt-go"
"golang.org/x/crypto/ssh/terminal"
)
2014-03-13 02:57:00 +01:00
func main() {
version := irc.SEM_VER
usage := `oragono.
Usage:
oragono initdb [--conf <filename>]
oragono upgradedb [--conf <filename>]
oragono genpasswd [--conf <filename>]
oragono run [--conf <filename>]
oragono -h | --help
oragono --version
Options:
--conf <filename> Configuration file to use [default: ircd.yaml].
-h --help Show this screen.
--version Show version.`
arguments, _ := docopt.Parse(usage, nil, true, version, false)
// load config now because it's the same process for all
configfile := arguments["--conf"].(string)
config, err := irc.LoadConfig(configfile)
2014-03-13 02:57:00 +01:00
if err != nil {
log.Fatal("Config file did not load successfully:", err.Error())
2014-03-13 02:57:00 +01:00
}
if arguments["genpasswd"].(bool) {
fmt.Print("Enter Password: ")
bytePassword, err := terminal.ReadPassword(int(syscall.Stdin))
if err != nil {
log.Fatal("Error reading password:", err.Error())
}
password := string(bytePassword)
encoded, err := irc.GenerateEncodedPassword(password)
if err != nil {
2014-03-13 02:57:00 +01:00
log.Fatalln("encoding error:", err)
}
fmt.Print("\n")
fmt.Println(encoded)
} else if arguments["initdb"].(bool) {
irc.InitDB(config.Server.Database)
2014-03-08 03:14:02 +01:00
log.Println("database initialized: ", config.Server.Database)
} else if arguments["upgradedb"].(bool) {
2014-03-08 03:14:02 +01:00
irc.UpgradeDB(config.Server.Database)
log.Println("database upgraded: ", config.Server.Database)
} else if arguments["run"].(bool) {
2014-03-13 02:57:00 +01:00
irc.Log.SetLevel(config.Server.Log)
server := irc.NewServer(config)
log.Println(irc.SEM_VER, "running")
defer log.Println(irc.SEM_VER, "exiting")
server.Run()
}
2014-02-08 22:18:11 +01:00
}