You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
922 B

  1. #!/bin/sh
  2. CONFIG=/etc/crowdsec/config.yaml
  3. data_dir=`uci get "crowdsec.crowdsec.data_dir"`
  4. sed -i "s,^\(\s*data_dir\s*:\s*\).*\$,\1$data_dir," $CONFIG
  5. db_path=`uci get "crowdsec.crowdsec.db_path"`
  6. sed -i "s,^\(\s*db_path\s*:\s*\).*\$,\1$db_path," $CONFIG
  7. # Create data dir & permissions if needed
  8. if [ ! -d "${data_dir}" ]; then
  9. mkdir -m 0755 -p "${data_dir}"
  10. fi;
  11. if grep -q "login:" /etc/crowdsec/local_api_credentials.yaml; then
  12. echo local API already registered...
  13. else
  14. cscli -c /etc/crowdsec/config.yaml machines add -a -f /etc/crowdsec/local_api_credentials.yaml
  15. fi
  16. if [ -s /etc/crowdsec/online_api_credentials.yaml ]; then
  17. echo online API already registered...
  18. else
  19. cscli -c /etc/crowdsec/config.yaml capi register -f /etc/crowdsec/online_api_credentials.yaml
  20. fi
  21. cscli hub update && cscli collections install crowdsecurity/linux && cscli parsers install crowdsecurity/whitelists && cscli hub upgrade
  22. exit 0