From afe1704aa6a13be7c4274a49c85fc9209a929876 Mon Sep 17 00:00:00 2001 From: Manuel Sabban Date: Tue, 15 Feb 2022 11:20:52 +0100 Subject: [PATCH] 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> --- debian/control | 1 + debian/postinst | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/debian/control b/debian/control index 8f812de54..b2d2bac20 100644 --- a/debian/control +++ b/debian/control @@ -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 \ No newline at end of file diff --git a/debian/postinst b/debian/postinst index 5c741aa55..7055e12f5 100644 --- a/debian/postinst +++ b/debian/postinst @@ -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