Chore: initial config with port
This commit is contained in:
parent
c808d8a84f
commit
344a9da335
1 changed files with 8 additions and 4 deletions
|
@ -38,15 +38,19 @@ func Init(dir string) error {
|
||||||
|
|
||||||
// initial config.yaml
|
// initial config.yaml
|
||||||
if _, err := os.Stat(C.Path.Config()); os.IsNotExist(err) {
|
if _, err := os.Stat(C.Path.Config()); os.IsNotExist(err) {
|
||||||
log.Infoln("Can't find config, create an empty file")
|
log.Infoln("Can't find config, create a initial config file")
|
||||||
os.OpenFile(C.Path.Config(), os.O_CREATE|os.O_WRONLY, 0644)
|
f, err := os.OpenFile(C.Path.Config(), os.O_CREATE|os.O_WRONLY, 0644)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Can't create file %s: %s", C.Path.Config(), err.Error())
|
||||||
|
}
|
||||||
|
f.Write([]byte(`port: 7890`))
|
||||||
|
f.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// initial mmdb
|
// initial mmdb
|
||||||
if _, err := os.Stat(C.Path.MMDB()); os.IsNotExist(err) {
|
if _, err := os.Stat(C.Path.MMDB()); os.IsNotExist(err) {
|
||||||
log.Infoln("Can't find MMDB, start download")
|
log.Infoln("Can't find MMDB, start download")
|
||||||
err := downloadMMDB(C.Path.MMDB())
|
if err := downloadMMDB(C.Path.MMDB()); err != nil {
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("Can't download MMDB: %s", err.Error())
|
return fmt.Errorf("Can't download MMDB: %s", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue