From a6adcdafa9d0289338d5e2808a4df5160431c5fc Mon Sep 17 00:00:00 2001 From: Juan Font Alonso Date: Mon, 27 Sep 2021 17:24:34 +0200 Subject: [PATCH] Added switch to disable the update checks --- cmd/headscale/headscale.go | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/cmd/headscale/headscale.go b/cmd/headscale/headscale.go index bc8f515b..f815001e 100644 --- a/cmd/headscale/headscale.go +++ b/cmd/headscale/headscale.go @@ -3,6 +3,7 @@ package main import ( "fmt" "os" + "runtime" "time" "github.com/efekarakus/termcolor" @@ -40,19 +41,6 @@ func main() { NoColor: !colors, }) - githubTag := &latest.GithubTag{ - Owner: "juanfont", - Repository: "headscale", - } - - if cli.Version != "dev" { - res, err := latest.Check(githubTag, cli.Version) - if err == nil && res.Outdated { - fmt.Printf("An updated version of Headscale has been found (%s vs. your current %s). Check it out https://github.com/juanfont/headscale/releases\n", - res.Current, cli.Version) - } - } - err := cli.LoadConfig("") if err != nil { log.Fatal().Err(err) @@ -74,5 +62,19 @@ func main() { zerolog.SetGlobalLevel(zerolog.DebugLevel) } + if !viper.GetBool("disable_check_updates") { + if (runtime.GOOS == "linux" || runtime.GOOS == "darwin") && cli.Version != "dev" { + githubTag := &latest.GithubTag{ + Owner: "juanfont", + Repository: "headscale", + } + res, err := latest.Check(githubTag, cli.Version) + if err == nil && res.Outdated { + fmt.Printf("An updated version of Headscale has been found (%s vs. your current %s). Check it out https://github.com/juanfont/headscale/releases\n", + res.Current, cli.Version) + } + } + } + cli.Execute() }