Skip to content

Commit

Permalink
setup: gate setup and check for keydir
Browse files Browse the repository at this point in the history
We don't need to run --migrate if there is no sbctl installed, so check
that first and then check the keydir if there is something there
already.

Signed-off-by: Morten Linderud <[email protected]>
  • Loading branch information
Foxboron committed Jul 31, 2024
1 parent b3ce9f7 commit de3aafc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cmd/sbctl/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,16 @@ func SetupInstallation(state *config.State) error {
}

func MigrateSetup(state *config.State) error {
if !state.IsInstalled() {
return fmt.Errorf("sbctl is not installd")
}

newConf := config.DefaultConfig()
p := path.Dir(newConf.Keydir)

// abort early if it exists
if ok, _ := afero.DirExists(state.Fs, p); ok {
logging.Print("%s already exists!\n", p)
if ok, _ := afero.DirExists(state.Fs, newConf.Keydir); ok {
logging.Println("sbctl has already been migrated!")
return nil
}

Expand Down

0 comments on commit de3aafc

Please sign in to comment.