|
@@ -13,7 +13,6 @@ import (
|
|
|
"gopkg.in/yaml.v2"
|
|
|
|
|
|
"github.com/crowdsecurity/crowdsec/pkg/csconfig"
|
|
|
- "github.com/crowdsecurity/crowdsec/pkg/types"
|
|
|
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
|
|
|
)
|
|
|
|
|
@@ -38,7 +37,7 @@ func restoreConfigFromDirectory(dirPath string, oldBackup bool) error {
|
|
|
backupMain := fmt.Sprintf("%s/config.yaml", dirPath)
|
|
|
if _, err = os.Stat(backupMain); err == nil {
|
|
|
if csConfig.ConfigPaths != nil && csConfig.ConfigPaths.ConfigDir != "" {
|
|
|
- if err = types.CopyFile(backupMain, fmt.Sprintf("%s/config.yaml", csConfig.ConfigPaths.ConfigDir)); err != nil {
|
|
|
+ if err = CopyFile(backupMain, fmt.Sprintf("%s/config.yaml", csConfig.ConfigPaths.ConfigDir)); err != nil {
|
|
|
return fmt.Errorf("failed copy %s to %s : %s", backupMain, csConfig.ConfigPaths.ConfigDir, err)
|
|
|
}
|
|
|
}
|
|
@@ -51,21 +50,21 @@ func restoreConfigFromDirectory(dirPath string, oldBackup bool) error {
|
|
|
|
|
|
backupCAPICreds := fmt.Sprintf("%s/online_api_credentials.yaml", dirPath)
|
|
|
if _, err = os.Stat(backupCAPICreds); err == nil {
|
|
|
- if err = types.CopyFile(backupCAPICreds, csConfig.API.Server.OnlineClient.CredentialsFilePath); err != nil {
|
|
|
+ if err = CopyFile(backupCAPICreds, csConfig.API.Server.OnlineClient.CredentialsFilePath); err != nil {
|
|
|
return fmt.Errorf("failed copy %s to %s : %s", backupCAPICreds, csConfig.API.Server.OnlineClient.CredentialsFilePath, err)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
backupLAPICreds := fmt.Sprintf("%s/local_api_credentials.yaml", dirPath)
|
|
|
if _, err = os.Stat(backupLAPICreds); err == nil {
|
|
|
- if err = types.CopyFile(backupLAPICreds, csConfig.API.Client.CredentialsFilePath); err != nil {
|
|
|
+ if err = CopyFile(backupLAPICreds, csConfig.API.Client.CredentialsFilePath); err != nil {
|
|
|
return fmt.Errorf("failed copy %s to %s : %s", backupLAPICreds, csConfig.API.Client.CredentialsFilePath, err)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
backupProfiles := fmt.Sprintf("%s/profiles.yaml", dirPath)
|
|
|
if _, err = os.Stat(backupProfiles); err == nil {
|
|
|
- if err = types.CopyFile(backupProfiles, csConfig.API.Server.ProfilesPath); err != nil {
|
|
|
+ if err = CopyFile(backupProfiles, csConfig.API.Server.ProfilesPath); err != nil {
|
|
|
return fmt.Errorf("failed copy %s to %s : %s", backupProfiles, csConfig.API.Server.ProfilesPath, err)
|
|
|
}
|
|
|
}
|
|
@@ -106,7 +105,7 @@ func restoreConfigFromDirectory(dirPath string, oldBackup bool) error {
|
|
|
|
|
|
backupSimulation := fmt.Sprintf("%s/simulation.yaml", dirPath)
|
|
|
if _, err = os.Stat(backupSimulation); err == nil {
|
|
|
- if err = types.CopyFile(backupSimulation, csConfig.ConfigPaths.SimulationFilePath); err != nil {
|
|
|
+ if err = CopyFile(backupSimulation, csConfig.ConfigPaths.SimulationFilePath); err != nil {
|
|
|
return fmt.Errorf("failed copy %s to %s : %s", backupSimulation, csConfig.ConfigPaths.SimulationFilePath, err)
|
|
|
}
|
|
|
}
|
|
@@ -123,7 +122,7 @@ func restoreConfigFromDirectory(dirPath string, oldBackup bool) error {
|
|
|
if _, err = os.Stat(backupAcquisition); err == nil {
|
|
|
log.Debugf("restoring backup'ed %s", backupAcquisition)
|
|
|
|
|
|
- if err = types.CopyFile(backupAcquisition, csConfig.Crowdsec.AcquisitionFilePath); err != nil {
|
|
|
+ if err = CopyFile(backupAcquisition, csConfig.Crowdsec.AcquisitionFilePath); err != nil {
|
|
|
return fmt.Errorf("failed copy %s to %s : %s", backupAcquisition, csConfig.Crowdsec.AcquisitionFilePath, err)
|
|
|
}
|
|
|
}
|
|
@@ -139,7 +138,7 @@ func restoreConfigFromDirectory(dirPath string, oldBackup bool) error {
|
|
|
|
|
|
log.Debugf("restoring %s to %s", acquisFile, targetFname)
|
|
|
|
|
|
- if err = types.CopyFile(acquisFile, targetFname); err != nil {
|
|
|
+ if err = CopyFile(acquisFile, targetFname); err != nil {
|
|
|
return fmt.Errorf("failed copy %s to %s : %s", acquisFile, targetFname, err)
|
|
|
}
|
|
|
}
|
|
@@ -160,7 +159,7 @@ func restoreConfigFromDirectory(dirPath string, oldBackup bool) error {
|
|
|
return errors.Wrapf(err, "while saving %s to %s", acquisFile, acquisBackupDir)
|
|
|
}
|
|
|
|
|
|
- if err = types.CopyFile(acquisFile, targetFname); err != nil {
|
|
|
+ if err = CopyFile(acquisFile, targetFname); err != nil {
|
|
|
return fmt.Errorf("failed copy %s to %s : %s", acquisFile, targetFname, err)
|
|
|
}
|
|
|
|