summaryrefslogtreecommitdiff
path: root/cmd/client/autoupdate.go
blob: 29a897945ff804b6c13bd8c2926c70952180b547 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package client

import (
	"context"
	"os"
)

// TODO:
// Check the Server header from the host and if the second part does not match
// - Use HEAD, ignore 404
// Download the latest client for this os/arch (remap GOARCH=amd64 to x86_64)
// Re-execute the client in the same process so the latest client is used
// Log some output to let the user know this happened
// Verify SHA256 based on server ETag
func upgradeAndRestartClient(ctx context.Context, version, host string) error {
	// Download, chmod, verify, unlink original, rename old to new, exec new
	exec, err := os.Executable()
	if err != nil {
		return err
	}
	_ = exec

	// Refuse if any path segment starts with go-build.*

	return nil
}