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()
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":

View File

@ -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