mirror of
				https://github.com/juanfont/headscale.git
				synced 2025-11-04 01:51:04 +01:00 
			
		
		
		
	Added switch to disable the update checks
This commit is contained in:
		
							parent
							
								
									7c37086dd6
								
							
						
					
					
						commit
						a6adcdafa9
					
				@ -3,6 +3,7 @@ package main
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
 | 
						"runtime"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/efekarakus/termcolor"
 | 
						"github.com/efekarakus/termcolor"
 | 
				
			||||||
@ -40,19 +41,6 @@ func main() {
 | 
				
			|||||||
		NoColor:    !colors,
 | 
							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("")
 | 
						err := cli.LoadConfig("")
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		log.Fatal().Err(err)
 | 
							log.Fatal().Err(err)
 | 
				
			||||||
@ -74,5 +62,19 @@ func main() {
 | 
				
			|||||||
		zerolog.SetGlobalLevel(zerolog.DebugLevel)
 | 
							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()
 | 
						cli.Execute()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user