summaryrefslogtreecommitdiff
path: root/cmd/client/autoupdate.go
blob: feb272eb0f3a120f67f43d18c67f0fce4041771d (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
27
28
package client

import (
	"context"
	"log"
	"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
	}

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

	log.Printf("Executable is %s", exec)

	return nil
}