View | Details | Raw Unified | Return to bug 260264 | Differences between
and this patch

Collapse All | Expand All

(-)b/security/crowdsec-firewall-bouncer/files/crowdsec_firewall.in (-3 / +2 lines)
Lines 30-39 start_precmd="${name}_precmd" Link Here
30
crowdsec_firewall_precmd() {
30
crowdsec_firewall_precmd() {
31
    CSCLI=%%PREFIX%%/bin/cscli
31
    CSCLI=%%PREFIX%%/bin/cscli
32
    orig_line="api_key: \${API_KEY}"
32
    orig_line="api_key: \${API_KEY}"
33
    if grep "^${orig_line}" "${crowdsec_firewall_config}"; then
33
    if grep -q "^${orig_line}" "${crowdsec_firewall_config}"; then
34
        SUFFIX=$(LC_CTYPE=C tr -dc A-Za-z0-9 </dev/urandom | head -c 8)
34
        SUFFIX=$(LC_CTYPE=C tr -dc A-Za-z0-9 </dev/urandom | head -c 8)
35
        BOUNCER="cs-firewall-bouncer-${SUFFIX}"
35
        BOUNCER="cs-firewall-bouncer-${SUFFIX}"
36
        if command -v $CSCLI; then
36
        if command -v "$CSCLI" >/dev/null; then
37
            API_KEY=$($CSCLI bouncers add "${BOUNCER}" -o raw)
37
            API_KEY=$($CSCLI bouncers add "${BOUNCER}" -o raw)
38
            if [ -n "$API_KEY" ]; then
38
            if [ -n "$API_KEY" ]; then
39
                sed -i "" "s/^${orig_line}/api_key: ${API_KEY}     # ${BOUNCER}/" "${crowdsec_firewall_config}"
39
                sed -i "" "s/^${orig_line}/api_key: ${API_KEY}     # ${BOUNCER}/" "${crowdsec_firewall_config}"
40
- 

Return to bug 260264