mirror of
https://github.com/syncthing/syncthing.git
synced 2024-11-16 18:41:59 -07:00
Create syncthing.ini template (fixes #39)
This commit is contained in:
parent
1dde9ec2d8
commit
20a47695fb
43
main.go
43
main.go
@ -124,6 +124,37 @@ func main() {
|
||||
log.SetPrefix("[" + myID[0:5] + "] ")
|
||||
logger.SetPrefix("[" + myID[0:5] + "] ")
|
||||
|
||||
// Load the configuration file, if it exists.
|
||||
// If it does not, create a template.
|
||||
|
||||
cfgFile := path.Join(opts.ConfDir, confFileName)
|
||||
cf, err := os.Open(cfgFile)
|
||||
|
||||
if err != nil {
|
||||
infoln("No config file; creating a template")
|
||||
config = ini.Config{}
|
||||
config.AddComment("repository", "Set the following to the directory you wish to synchronize")
|
||||
config.AddComment("repository", "dir = ~/Syncthing")
|
||||
config.Set("nodes", myID, "auto")
|
||||
config.AddComment("nodes", "Add peer nodes here")
|
||||
fd, err := os.Create(cfgFile)
|
||||
if err != nil {
|
||||
fatalln(err)
|
||||
}
|
||||
config.Write(fd)
|
||||
fd.Close()
|
||||
infof("Edit %s to suit and restart syncthing.", cfgFile)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
config = ini.Parse(cf)
|
||||
cf.Close()
|
||||
|
||||
var dir = expandTilde(config.Get("repository", "dir"))
|
||||
if len(dir) == 0 {
|
||||
fatalln("No repository directory. Set dir under [repository] in syncthing.ini.")
|
||||
}
|
||||
|
||||
if opts.Debug.Profiler != "" {
|
||||
go func() {
|
||||
err := http.ListenAndServe(opts.Debug.Profiler, nil)
|
||||
@ -146,18 +177,6 @@ func main() {
|
||||
MinVersion: tls.VersionTLS12,
|
||||
}
|
||||
|
||||
// Load the configuration file, if it exists.
|
||||
|
||||
cf, err := os.Open(path.Join(opts.ConfDir, confFileName))
|
||||
if err != nil {
|
||||
fatalln("No config file")
|
||||
config = ini.Config{}
|
||||
}
|
||||
config = ini.Parse(cf)
|
||||
cf.Close()
|
||||
|
||||
var dir = expandTilde(config.Get("repository", "dir"))
|
||||
|
||||
// Create a map of desired node connections based on the configuration file
|
||||
// directives.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user