From a4daa28e26390ee1f27db952a53c196794efdf3c Mon Sep 17 00:00:00 2001 From: David Dworken Date: Sun, 3 Apr 2022 21:27:32 -0700 Subject: [PATCH] before refactoring to drop the old 'remote' client --- clients/local/client.go | 2 -- shared/client.go | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/clients/local/client.go b/clients/local/client.go index 2397703..ef4ef44 100644 --- a/clients/local/client.go +++ b/clients/local/client.go @@ -25,10 +25,8 @@ func main() { export() case "init": shared.CheckFatalError(shared.Setup( os.Args)) - // TODO: Call ebootstrap here case "install": shared.CheckFatalError(shared.Install()) - // TODO: Call ebootstrap here case "enable": shared.CheckFatalError(shared.Enable()) case "disable": diff --git a/shared/client.go b/shared/client.go index e57b9ae..5587bcf 100644 --- a/shared/client.go +++ b/shared/client.go @@ -17,6 +17,8 @@ import ( "strconv" "strings" "time" + "net/http" + "github.com/fatih/color" "github.com/google/uuid" @@ -131,7 +133,17 @@ func Setup(args []string) error { config.UserSecret = userSecret config.IsEnabled = true config.DeviceId = uuid.Must(uuid.NewRandom()).String() - return SetConfig(config) + + err := SetConfig(config) + if err != nil { + return fmt.Errorf("failed to persist config to disk: %v", err) + } + + + _, err = http.Get(getServerHostname()+"/api/v1/eregister?user_id=" + shared.UserId(userSecret) + "&device_id=" + config.DeviceId) + if err != nil { + return fmt.Errorf("failed to register device with backend: %v", err) + } } func DisplayResults(results []*HistoryEntry, displayHostname bool) { @@ -252,7 +264,6 @@ func Install() error { _, err = GetConfig() if err != nil { // No config, so set up a new installation - // TODO: GO THROUGH THE REGISTRATION FLOW return Setup(os.Args) } return nil