From: Sergey Matveev Date: Sun, 12 Mar 2023 10:14:56 +0000 (+0300) Subject: No hardcoded entrypoint X-Git-Url: http://www.git.stargrave.org/?p=mmc.git;a=commitdiff_plain;h=832176e643f73d8628c112311f1dd295f9f88499 No hardcoded entrypoint --- diff --git a/cmd/ch-leave/main.go b/cmd/ch-leave/main.go index 00e6311..0d09e2d 100644 --- a/cmd/ch-leave/main.go +++ b/cmd/ch-leave/main.go @@ -25,7 +25,7 @@ import ( ) func main() { - entrypoint := flag.String("entrypoint", "mm.rnd.stcnet.ru", "Entrypoint") + entrypoint := flag.String("entrypoint", mmc.GetEntrypoint(), "Entrypoint") flag.Parse() log.SetFlags(log.Lshortfile) diff --git a/cmd/mmc/main.go b/cmd/mmc/main.go index 20c8da4..e1b2c29 100644 --- a/cmd/mmc/main.go +++ b/cmd/mmc/main.go @@ -58,7 +58,7 @@ func rewriteIfChanged(fn string, data string) { } func main() { - entrypoint := flag.String("entrypoint", "mm.rnd.stcnet.ru", "Entrypoint") + entrypoint := flag.String("entrypoint", mmc.GetEntrypoint(), "Entrypoint") notifyCmd := flag.String("notify", "cmd/notify", "Path to notification handler") heartbeatCh := flag.String("heartbeat-ch", "town-square", "Channel for heartbeating") flag.Parse() diff --git a/cmd/scrollback/main.go b/cmd/scrollback/main.go index aab3312..733b571 100644 --- a/cmd/scrollback/main.go +++ b/cmd/scrollback/main.go @@ -29,7 +29,7 @@ import ( const PerPage = 100 func main() { - entrypoint := flag.String("entrypoint", "mm.rnd.stcnet.ru", "Entrypoint") + entrypoint := flag.String("entrypoint", mmc.GetEntrypoint(), "Entrypoint") pageNum := flag.Int("page", 0, "Page number") direct := flag.Bool("direct", false, "Direct channel") flag.Parse() diff --git a/common.go b/common.go index 0412601..e0e2b3e 100644 --- a/common.go +++ b/common.go @@ -101,3 +101,11 @@ func GetUsers(c *model.Client4, debugFd *os.File) (map[string]*model.User, error } return users, nil } + +func GetEntrypoint() string { + s := os.Getenv("MMC_ENTRYPOINT") + if s == "" { + return "mm.invalid" + } + return s +} diff --git a/doc/usage.texi b/doc/usage.texi index cfd8046..d64b999 100644 --- a/doc/usage.texi +++ b/doc/usage.texi @@ -10,7 +10,9 @@ compile Go programs in @file{cmd} subdirectory. @item Place your MM's credentials to @env{$NETRC} (@file{~/.netrc} by default). For example -@code{machine mm.example.com login stargrave@@mm.example.com password PASSWORD}. +@code{machine mm.invalid login stargrave@@mm.invalid password PASSWORD}. + +@item Set @env{$MMC_ENTRYPOINT} environment variable to your entrypoint. @item Run @command{cmd/start} and you should see started @command{tmux} with split window and running @command{cmd/mmc}.