From 0f03096ed2ad7bd7c7a61b6ea3dd1838616c3088 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Sat, 7 Jun 2025 14:20:49 -0400 Subject: [PATCH] Default to online mode in init --- core/init.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/core/init.go b/core/init.go index c9a86dc..100efd2 100644 --- a/core/init.go +++ b/core/init.go @@ -16,8 +16,21 @@ import ( // LibmuttonInit creates the libmutton config structure based on user input. // rcwPassphrase and clientSpecificIniData can be left blank if not needed. func LibmuttonInit(inputCB func(prompt string) string, clientSpecificIniData [][3]string, rcwPassphrase []byte, preserveOldConfigDir bool) error { - r := strings.ToLower(inputCB("Configure SSH settings (for synchronization)? (y/N)")) - if len(r) > 0 && r[0] == 'y' { + r := strings.ToLower(inputCB("Configure SSH settings (for synchronization)? (Y/n)")) + if len(r) > 0 && r[0] == 'n' { + // initialize libmutton directories + _, err := global.DirInit(preserveOldConfigDir) + if err != nil { + return errors.New("unable to initialize libmutton directories: " + err.Error()) + } + // write config file + if len(clientSpecificIniData) > 0 { + err = cfg.WriteConfig(append(clientSpecificIniData, [][3]string{{"LIBMUTTON", "offlineMode", "true"}}...), nil, false) + if err != nil { + return errors.New("unable to write config file: " + err.Error()) + } + } + } else { // ensure ssh key file exists (and is a file) fallbackSSHKey := back.Home + global.PathSeparator + ".ssh" + global.PathSeparator + "id_ed25519" sshKeyPath := cmp.Or(back.ExpandPathWithHome(inputCB(back.AnsiBold+"Note:"+back.AnsiReset+" Only key-based authentication is supported (keys may optionally be passphrase-protected).\n The remote server must already be in your ~"+global.PathSeparator+".ssh"+global.PathSeparator+"known_hosts file.\n\nSSH private identity file path (falls back to \""+fallbackSSHKey+"\"):")), fallbackSSHKey) @@ -67,19 +80,6 @@ func LibmuttonInit(inputCB func(prompt string) string, clientSpecificIniData [][ if err != nil { return errors.New("unable to write config file: " + err.Error()) } - } else { - // initialize libmutton directories - _, err := global.DirInit(preserveOldConfigDir) - if err != nil { - return errors.New("unable to initialize libmutton directories: " + err.Error()) - } - // write config file - if len(clientSpecificIniData) > 0 { - err = cfg.WriteConfig(append(clientSpecificIniData, [][3]string{{"LIBMUTTON", "offlineMode", "true"}}...), nil, false) - if err != nil { - return errors.New("unable to write config file: " + err.Error()) - } - } } // generate rcw sanity check file (if requested) if len(rcwPassphrase) > 0 {