ref: master
./main.go
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
package main import ( "notabug.org/apiote/amuse/config" "notabug.org/apiote/amuse/db" "notabug.org/apiote/amuse/libamuse" "flag" "fmt" "os" "log" ) func main() { port := flag.Int("p", -1, "port to run amuse on") address := flag.String("a", "", "address to run amuse on") dataHome := flag.String("d", "", "data directory") manage := flag.String("m", "", "manage command") configPath := flag.String("c", "/etc/amuse.toml", "configPath") flag.Parse() config.ReadConfig(*configPath) if *dataHome != "" { config.DataHome = *dataHome } if *port > 0 { config.Port = uint(*port) } if *address != "" { config.Address = *address } validateState() db.Migrate() switch *manage { case "makeadmin": var username string fmt.Printf("Username: ") fmt.Scanf("%s", &username) err := libamuse.MakeAdmin(username) if err != nil { os.Exit(1) } else { return } case "touch": err := libamuse.TouchWantlist() if err != nil { os.Exit(1) } else { return } } route(config.Port) } func validateState() { _, err := os.Readlink(config.DataHome + "/i18n/default.toml") if err != nil { log.Println("WARN: i18n/default.toml is not a symbolic link; translations fallback will not work") } if config.TmdbApiKey == "" { log.Fatalln("ERR: TmdbApiKey not specified in config") } } |