diff options
author | Mike Crute <mike@crute.us> | 2023-08-19 19:10:51 -0700 |
---|---|---|
committer | Mike Crute <mike@crute.us> | 2023-08-19 22:17:50 -0700 |
commit | d49a29a4015026a012a03a2ebb3f8f845decb2d4 (patch) | |
tree | 98bbe15f11e092184df7044fb99cd7921aebb5a6 /cmd/client/autoupdate.go | |
parent | 7655a82ee0bff121aec08edcbaa3f799d34453b2 (diff) | |
download | websocket_proxy-d49a29a4015026a012a03a2ebb3f8f845decb2d4.tar.bz2 websocket_proxy-d49a29a4015026a012a03a2ebb3f8f845decb2d4.tar.xz websocket_proxy-d49a29a4015026a012a03a2ebb3f8f845decb2d4.zip |
WIP upgrade
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 | } | ||