fix upgrade when somthing is already listening on 8080 (#1258)

* this should fix issue #1245
* change cmdline for getting port

Co-authored-by: sabban <15465465+sabban@users.noreply.github.com>
This commit is contained in:
Manuel Sabban 2022-02-15 11:20:52 +01:00 committed by GitHub
parent 1d156ab19d
commit afe1704aa6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

1
debian/control vendored
View file

@ -5,3 +5,4 @@ Build-Depends: debhelper, jq, bash, git
Package: crowdsec
Architecture: any
Description: Crowdsec - An open-source, lightweight agent to detect and respond to bad behaviours. It also automatically benefits from our global community-wide IP reputation database
Depends: coreutils

5
debian/postinst vendored
View file

@ -89,10 +89,11 @@ if [ "$1" = configure ]; then
systemctl --quiet is-enabled crowdsec || systemctl unmask crowdsec && systemctl enable crowdsec
if [ -z "$(ss -nlt 'sport = 8080' | grep -v ^State)" ] || [ "$LAPI" = false ]; then
PORT=$(cscli config show --key "Config.API.Server.ListenURI"|cut -d ":" -f2)
if [ -z "$(ss -nlt "sport = ${PORT}" | grep -v ^State)" ] || [ "$LAPI" = false ] ; then
systemctl start crowdsec
else
echo "Not attempting to start crowdsec, port 8080 is already used or lapi was disabled"
echo "Not attempting to start crowdsec, port ${PORT} is already used or lapi was disabled"
echo "This port is configured through /etc/crowdsec/config.yaml and /etc/crowdsec/local_api_credentials.yaml"
fi
fi