hostinfo: [windows] check if running via Scoop (#7068)

You can now install Tailscale on Windows via [Scoop](https://scoop.sh).

This change adds a check to `packageTypeWindows()`, looking at the exe's path, and
checking if it starts with: `C:\User\<NAME>\scoop\apps\tailscale`. If so, it
returns `"scoop"` as the package type.

Fixes: #6988

Signed-off-by: Shayne Sweeney <shayne@tailscale.com>
This commit is contained in:
shayne 2023-01-25 16:58:23 -05:00 committed by GitHub
parent 038d25bd04
commit 6f992909f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,7 @@
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"strings"
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
"golang.org/x/sys/windows/registry" "golang.org/x/sys/windows/registry"
@ -69,6 +70,10 @@ func packageTypeWindows() string {
if err != nil { if err != nil {
return "" return ""
} }
home, _ := os.UserHomeDir()
if strings.HasPrefix(exe, filepath.Join(home, "scoop", "apps", "tailscale")) {
return "scoop"
}
dir := filepath.Dir(exe) dir := filepath.Dir(exe)
nsisUninstaller := filepath.Join(dir, "Uninstall-Tailscale.exe") nsisUninstaller := filepath.Join(dir, "Uninstall-Tailscale.exe")
_, err = os.Stat(nsisUninstaller) _, err = os.Stat(nsisUninstaller)