Warn if it did not replace the bouncer key

This commit is contained in:
Owen 2025-03-03 15:43:26 -05:00
parent a456a37b2f
commit 37fdc4a6a8
No known key found for this signature in database
GPG key ID: 8271FDFFD9E0CCBD

View file

@ -82,6 +82,11 @@ func installCrowdsec(config Config) error {
return fmt.Errorf("failed to restart containers: %v", err)
}
if checkIfTextInFile("config/traefik/dynamic_config.yml", "PUT_YOUR_BOUNCER_KEY_HERE_OR_IT_WILL_NOT_WORK") {
fmt.Println("Failed to replace bouncer key! Please retrieve the key and replace it in the config/traefik/dynamic_config.yml file using the following command:")
fmt.Println(" docker exec crowdsec cscli bouncers add traefik-bouncer")
}
return nil
}
@ -119,3 +124,14 @@ func GetCrowdSecAPIKey() (string, error) {
return apiKey, nil
}
func checkIfTextInFile(file, text string) bool {
// Read file
content, err := os.ReadFile(file)
if err != nil {
return false
}
// Check for text
return bytes.Contains(content, []byte(text))
}