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