mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-08-27 20:36:29 -04:00
Default to online mode in init
This commit is contained in:
+15
-15
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user