github.com/crowdsecurity/crowdsec@v1.6.1/test/bin/preload-hub-items (about)

     1  #!/usr/bin/env bash
     2  
     3  set -eu
     4  
     5  # shellcheck disable=SC1007
     6  THIS_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
     7  # shellcheck disable=SC1091
     8  . "${THIS_DIR}/../.environment.sh"
     9  
    10  # pre-download everything but don't install anything
    11  
    12  echo "Pre-downloading Hub content..."
    13  
    14  types=$("$CSCLI" hub types -o raw)
    15  
    16  for itemtype in $types; do
    17      ALL_ITEMS=$("$CSCLI" "$itemtype" list -a -o json | itemtype="$itemtype" yq '.[env(itemtype)][] | .name')
    18      if [[ -n "${ALL_ITEMS}" ]]; then
    19          #shellcheck disable=SC2086
    20          "$CSCLI" "$itemtype" install \
    21              $ALL_ITEMS \
    22              --download-only \
    23              --error
    24      fi
    25  done
    26  
    27  echo " done."