File: postinst

package info (click to toggle)
crowdsec-custom-bouncer 0.0.15-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 652 kB
  • sloc: sh: 171; makefile: 65
file content (38 lines) | stat: -rw-r--r-- 1,006 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

systemctl daemon-reload


START=0

if [ "$1" = "configure" ] && [ "$2" = "" ]; then

    type cscli

    if [ "$?" -eq "0" ] ; then
        START=1
        echo "cscli/crowdsec is present, generating API key"
        unique=`date +%s`
        API_KEY=`cscli -oraw bouncers add CustomBouncer-${unique}`
        if [ $? -eq 1 ] ; then
            echo "failed to create API token, service won't be started."
            START=0
            API_KEY="<API_KEY>"
        else
            echo "API Key : ${API_KEY}"
        fi

        TMP=`mktemp -p /tmp/`
        cp /etc/crowdsec/bouncers/crowdsec-custom-bouncer.yaml ${TMP}
        API_KEY=${API_KEY} envsubst < ${TMP} > /etc/crowdsec/bouncers/crowdsec-custom-bouncer.yaml
        rm ${TMP}
    fi
else
    START=1
fi


if [ ${START} -eq 0 ] ; then
    echo "no api key was generated"
fi

echo "please enter the binary path in '/etc/crowdsec/bouncers/crowdsec-custom-bouncer.yaml' and start the bouncer via 'sudo systemctl start crowdsec-custom-bouncer' "