diff options
Diffstat (limited to 'cmd/client/autoupdate.go')
-rw-r--r-- | cmd/client/autoupdate.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/cmd/client/autoupdate.go b/cmd/client/autoupdate.go new file mode 100644 index 0000000..feb272e --- /dev/null +++ b/cmd/client/autoupdate.go | |||
@@ -0,0 +1,28 @@ | |||
1 | package client | ||
2 | |||
3 | import ( | ||
4 | "context" | ||
5 | "log" | ||
6 | "os" | ||
7 | ) | ||
8 | |||
9 | // TODO: | ||
10 | // Check the Server header from the host and if the second part does not match | ||
11 | // - Use HEAD, ignore 404 | ||
12 | // Download the latest client for this os/arch (remap GOARCH=amd64 to x86_64) | ||
13 | // Re-execute the client in the same process so the latest client is used | ||
14 | // Log some output to let the user know this happened | ||
15 | // Verify SHA256 based on server ETag | ||
16 | func upgradeAndRestartClient(ctx context.Context, version, host string) error { | ||
17 | // Download, chmod, verify, unlink original, rename old to new, exec new | ||
18 | exec, err := os.Executable() | ||
19 | if err != nil { | ||
20 | return err | ||
21 | } | ||
22 | |||
23 | // Refuse if any path segment starts with go-build.* | ||
24 | |||
25 | log.Printf("Executable is %s", exec) | ||
26 | |||
27 | return nil | ||
28 | } | ||