Fix 1314 (#1320)
* fix https://github.com/crowdsecurity/crowdsec/issues/1314 * fix postinst logic * fix in rpm as well Co-authored-by: sabban <15465465+sabban@users.noreply.github.com>
This commit is contained in:
parent
e7de05d6c9
commit
bec231c1e6
2 changed files with 24 additions and 7 deletions
7
debian/postinst
vendored
7
debian/postinst
vendored
|
@ -89,8 +89,13 @@ if [ "$1" = configure ]; then
|
|||
|
||||
systemctl --quiet is-enabled crowdsec || systemctl unmask crowdsec && systemctl enable crowdsec
|
||||
|
||||
API=$(cscli config show --key "Config.API.Server")
|
||||
if [ "$API" = "<nil>" ] ; then
|
||||
LAPI=false
|
||||
else
|
||||
PORT=$(cscli config show --key "Config.API.Server.ListenURI"|cut -d ":" -f2)
|
||||
if [ -z "$(ss -nlt "sport = ${PORT}" | grep -v ^State)" ] || [ "$LAPI" = false ] ; then
|
||||
fi
|
||||
if [ "$LAPI" = false ] || [ -z "$(ss -nlt "sport = ${PORT}" | grep -v ^State)" ] ; then
|
||||
systemctl start crowdsec
|
||||
else
|
||||
echo "Not attempting to start crowdsec, port ${PORT} is already used or lapi was disabled"
|
||||
|
|
|
@ -143,6 +143,7 @@ fi
|
|||
|
||||
%post -p /bin/bash
|
||||
|
||||
#install
|
||||
if [ $1 == 1 ]; then
|
||||
|
||||
if [ ! -f "/var/lib/crowdsec/data/crowdsec.db" ] ; then
|
||||
|
@ -177,7 +178,7 @@ if [ $1 == 1 ]; then
|
|||
cscli hub update
|
||||
CSCLI_BIN_INSTALLED="/usr/bin/cscli" SILENT=true install_collection
|
||||
|
||||
|
||||
#upgrade
|
||||
elif [ $1 == 2 ] && [ -d /var/lib/crowdsec/backup ]; then
|
||||
cscli config restore /var/lib/crowdsec/backup
|
||||
if [ $? == 0 ]; then
|
||||
|
@ -196,10 +197,21 @@ fi
|
|||
%systemd_post %{name}.service
|
||||
|
||||
if [ $1 == 1 ]; then
|
||||
API=$(cscli config show --key "Config.API.Server")
|
||||
if [ "$API" = "<nil>" ] ; then
|
||||
LAPI=false
|
||||
else
|
||||
PORT=$(cscli config show --key "Config.API.Server.ListenURI"|cut -d ":" -f2)
|
||||
fi
|
||||
if [ "$LAPI" = false ] || [ -z "$(ss -nlt "sport = ${PORT}" | grep -v ^State)" ] ; then
|
||||
%if 0%{?fc35}
|
||||
systemctl enable crowdsec
|
||||
%endif
|
||||
systemctl start crowdsec || echo "crowdsec is not started"
|
||||
else
|
||||
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
|
||||
|
||||
%preun
|
||||
|
|
Loading…
Reference in a new issue