mirror of
https://github.com/syncthing/syncthing.git
synced 2024-11-16 18:41:59 -07:00
-generate
flag should also create config.xml (closes #847).
This commit is contained in:
parent
964d17d05a
commit
f6f6f261ed
@ -193,7 +193,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
l.Fatalln("home:", err)
|
l.Fatalln("home:", err)
|
||||||
}
|
}
|
||||||
flag.StringVar(&generateDir, "generate", "", "Generate key in specified dir, then exit")
|
flag.StringVar(&generateDir, "generate", "", "Generate key and config in specified dir, then exit")
|
||||||
flag.StringVar(&guiAddress, "gui-address", guiAddress, "Override GUI address")
|
flag.StringVar(&guiAddress, "gui-address", guiAddress, "Override GUI address")
|
||||||
flag.StringVar(&guiAuthentication, "gui-authentication", guiAuthentication, "Override GUI authentication; username:password")
|
flag.StringVar(&guiAuthentication, "gui-authentication", guiAuthentication, "Override GUI authentication; username:password")
|
||||||
flag.StringVar(&guiAPIKey, "gui-apikey", guiAPIKey, "Override GUI API key")
|
flag.StringVar(&guiAPIKey, "gui-apikey", guiAPIKey, "Override GUI API key")
|
||||||
@ -239,17 +239,31 @@ func main() {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
l.Warnln("Key exists; will not overwrite.")
|
l.Warnln("Key exists; will not overwrite.")
|
||||||
l.Infoln("Device ID:", protocol.NewDeviceID(cert.Certificate[0]))
|
l.Infoln("Device ID:", protocol.NewDeviceID(cert.Certificate[0]))
|
||||||
return
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
newCertificate(dir, "")
|
newCertificate(dir, "")
|
||||||
cert, err = loadCert(dir, "")
|
cert, err = loadCert(dir, "")
|
||||||
|
myID = protocol.NewDeviceID(cert.Certificate[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Fatalln("load cert:", err)
|
l.Fatalln("load cert:", err)
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
l.Infoln("Device ID:", protocol.NewDeviceID(cert.Certificate[0]))
|
l.Infoln("Device ID:", protocol.NewDeviceID(cert.Certificate[0]))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cfgFile := filepath.Join(dir, "config.xml")
|
||||||
|
if _, err := os.Stat(cfgFile); err == nil {
|
||||||
|
l.Warnln("Config exists; will not overwrite.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var myName, _ = os.Hostname()
|
||||||
|
var newCfg = defaultConfig(myName)
|
||||||
|
var cfg = config.Wrap(cfgFile, newCfg)
|
||||||
|
err = cfg.Save()
|
||||||
|
if err != nil {
|
||||||
|
l.Warnln("Failed to save config", err)
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user