From bd578c3c8340eb1ea06d95e8b1d19be00752a47d Mon Sep 17 00:00:00 2001 From: Cyril Brulebois Date: Mon, 1 Mar 2021 20:40:04 +0000 Subject: [PATCH] Automatically enable the online hub By default, crowdsec comes with an offline copy of the hub (see README.Debian). When running `cscli hub update`, ensure switching from this offline copy to the online hub. To ensure cscli doesn't disable anything that was configured (due to symlinks from /etc/crowdsec becoming dangling all of a sudden), copy the offline hub in the live directory (/var/lib/crowdsec/hub), and let further operations (`cscli hub upgrade`, or `cscli install`) update the live directory as required. Signed-off-by: Cyril Brulebois Gbp-Pq: Name 0007-automatically-enable-online-hub.patch --- cmd/crowdsec-cli/hub.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/crowdsec-cli/hub.go b/cmd/crowdsec-cli/hub.go index 28172ae..584bb5c 100644 --- a/cmd/crowdsec-cli/hub.go +++ b/cmd/crowdsec-cli/hub.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "os/exec" "github.com/crowdsecurity/crowdsec/pkg/cwhub" @@ -77,6 +78,12 @@ Fetches the [.index.json](https://github.com/crowdsecurity/hub/blob/master/.inde return nil }, Run: func(cmd *cobra.Command, args []string) { + /* Make sure to move away from the offline hub (see README.Debian) */ + command := exec.Command("/var/lib/dpkg/info/crowdsec.postinst", "enable-online-hub") + if err := command.Run(); err != nil { + log.Printf("Enabling Online Hub failed with error: %v", err) + } + if err := cwhub.UpdateHubIdx(csConfig.Cscli); err != nil { log.Fatalf("Failed to get Hub index : %v", err) } -- 2.30.2