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