before refactoring to drop the old 'remote' client

This commit is contained in:
David Dworken 2022-04-03 21:27:32 -07:00
parent c5eea01a23
commit a4daa28e26
2 changed files with 13 additions and 4 deletions

View File

@ -25,10 +25,8 @@ func main() {
export() export()
case "init": case "init":
shared.CheckFatalError(shared.Setup( os.Args)) shared.CheckFatalError(shared.Setup( os.Args))
// TODO: Call ebootstrap here
case "install": case "install":
shared.CheckFatalError(shared.Install()) shared.CheckFatalError(shared.Install())
// TODO: Call ebootstrap here
case "enable": case "enable":
shared.CheckFatalError(shared.Enable()) shared.CheckFatalError(shared.Enable())
case "disable": case "disable":

View File

@ -17,6 +17,8 @@ import (
"strconv" "strconv"
"strings" "strings"
"time" "time"
"net/http"
"github.com/fatih/color" "github.com/fatih/color"
"github.com/google/uuid" "github.com/google/uuid"
@ -131,7 +133,17 @@ func Setup(args []string) error {
config.UserSecret = userSecret config.UserSecret = userSecret
config.IsEnabled = true config.IsEnabled = true
config.DeviceId = uuid.Must(uuid.NewRandom()).String() 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) { func DisplayResults(results []*HistoryEntry, displayHostname bool) {
@ -252,7 +264,6 @@ func Install() error {
_, err = GetConfig() _, err = GetConfig()
if err != nil { if err != nil {
// No config, so set up a new installation // No config, so set up a new installation
// TODO: GO THROUGH THE REGISTRATION FLOW
return Setup(os.Args) return Setup(os.Args)
} }
return nil return nil