From: Cyril Brulebois Date: Mon, 1 Mar 2021 20:40:04 +0000 (+0000) Subject: Automatically enable the online hub X-Git-Tag: archive/raspbian/1.4.6-4+rpi1^2~9 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=fff812d41f354b690fb71ce44d9e5913dbe47a1f;p=crowdsec.git 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 --- diff --git a/cmd/crowdsec-cli/hub.go b/cmd/crowdsec-cli/hub.go index 6b35eb6..39c51ba 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/fatih/color" log "github.com/sirupsen/logrus" @@ -84,6 +85,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 := csConfig.LoadHub(); err != nil { log.Fatal(err) }