cscli: restore config correctly if acquis.d already exists (#2504)
This commit is contained in:
parent
bfda483c0a
commit
cba6de024f
|
@ -11,7 +11,8 @@ import (
|
||||||
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
|
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* Backup crowdsec configurations to directory <dirPath> :
|
/*
|
||||||
|
Backup crowdsec configurations to directory <dirPath>:
|
||||||
|
|
||||||
- Main config (config.yaml)
|
- Main config (config.yaml)
|
||||||
- Profiles config (profiles.yaml)
|
- Profiles config (profiles.yaml)
|
||||||
|
@ -19,6 +20,7 @@ import (
|
||||||
- Backup of API credentials (local API and online API)
|
- Backup of API credentials (local API and online API)
|
||||||
- List of scenarios, parsers, postoverflows and collections that are up-to-date
|
- List of scenarios, parsers, postoverflows and collections that are up-to-date
|
||||||
- Tainted/local/out-of-date scenarios, parsers, postoverflows and collections
|
- Tainted/local/out-of-date scenarios, parsers, postoverflows and collections
|
||||||
|
- Acquisition files (acquis.yaml, acquis.d/*.yaml)
|
||||||
*/
|
*/
|
||||||
func backupConfigToDirectory(dirPath string) error {
|
func backupConfigToDirectory(dirPath string) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
|
@ -20,7 +20,8 @@ type OldAPICfg struct {
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Restore crowdsec configurations to directory <dirPath> :
|
/*
|
||||||
|
Restore crowdsec configurations to directory <dirPath>:
|
||||||
|
|
||||||
- Main config (config.yaml)
|
- Main config (config.yaml)
|
||||||
- Profiles config (profiles.yaml)
|
- Profiles config (profiles.yaml)
|
||||||
|
@ -28,6 +29,7 @@ type OldAPICfg struct {
|
||||||
- Backup of API credentials (local API and online API)
|
- Backup of API credentials (local API and online API)
|
||||||
- List of scenarios, parsers, postoverflows and collections that are up-to-date
|
- List of scenarios, parsers, postoverflows and collections that are up-to-date
|
||||||
- Tainted/local/out-of-date scenarios, parsers, postoverflows and collections
|
- Tainted/local/out-of-date scenarios, parsers, postoverflows and collections
|
||||||
|
- Acquisition files (acquis.yaml, acquis.d/*.yaml)
|
||||||
*/
|
*/
|
||||||
func restoreConfigFromDirectory(dirPath string, oldBackup bool) error {
|
func restoreConfigFromDirectory(dirPath string, oldBackup bool) error {
|
||||||
var err error
|
var err error
|
||||||
|
@ -111,7 +113,7 @@ func restoreConfigFromDirectory(dirPath string, oldBackup bool) error {
|
||||||
|
|
||||||
/*if there is a acquisition dir, restore its content*/
|
/*if there is a acquisition dir, restore its content*/
|
||||||
if csConfig.Crowdsec.AcquisitionDirPath != "" {
|
if csConfig.Crowdsec.AcquisitionDirPath != "" {
|
||||||
if err = os.Mkdir(csConfig.Crowdsec.AcquisitionDirPath, 0o700); err != nil {
|
if err = os.MkdirAll(csConfig.Crowdsec.AcquisitionDirPath, 0o700); err != nil {
|
||||||
return fmt.Errorf("error while creating %s : %s", csConfig.Crowdsec.AcquisitionDirPath, err)
|
return fmt.Errorf("error while creating %s : %s", csConfig.Crowdsec.AcquisitionDirPath, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue