main.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //go:generate goversioninfo -icon=windowsdata/resource/netmaker.ico -manifest=netclient.exe.manifest.xml -64=true -o=netclient.syso
  2. package main
  3. import (
  4. "log"
  5. "os"
  6. "runtime/debug"
  7. "github.com/gravitl/netmaker/netclient/cli_options"
  8. "github.com/gravitl/netmaker/netclient/ncutils"
  9. "github.com/gravitl/netmaker/netclient/ncwindows"
  10. "github.com/urfave/cli/v2"
  11. )
  12. var version = "dev"
  13. func main() {
  14. app := cli.NewApp()
  15. app.Name = "Netclient"
  16. app.Version = version
  17. ncutils.SetVersion(version)
  18. cliFlags := cli_options.GetFlags(ncutils.GetHostname())
  19. app.Commands = cli_options.GetCommands(cliFlags[:])
  20. app.Description = "Used to perform interactions with Netmaker server and set local WireGuard config."
  21. app.Usage = "Netmaker's netclient agent and CLI."
  22. app.UsageText = "netclient [global options] command [command options] [arguments...]. Adjust verbosity of given command with -v, -vv or -vvv (max)."
  23. setGarbageCollection()
  24. if ncutils.IsWindows() {
  25. ncwindows.InitWindows()
  26. } else {
  27. ncutils.CheckUID()
  28. ncutils.CheckWG()
  29. }
  30. err := app.Run(os.Args)
  31. if err != nil {
  32. log.Fatal(err)
  33. }
  34. }
  35. func setGarbageCollection() {
  36. _, gcset := os.LookupEnv("GOGC")
  37. if !gcset {
  38. debug.SetGCPercent(ncutils.DEFAULT_GC_PERCENT)
  39. }
  40. }