-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #148 from crowdsecurity/port
improve port management as well for rpm
- Loading branch information
Showing
1 changed file
with
25 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,8 +57,9 @@ rm -rf %{buildroot} | |
|
||
systemctl daemon-reload | ||
|
||
|
||
START=0 | ||
CSCLI=/usr/bin/cscli | ||
|
||
if [ "$1" == "1" ] ; then | ||
type cscli > /dev/null | ||
|
||
|
@@ -84,6 +85,13 @@ else | |
START=1 | ||
fi | ||
|
||
if command -v "$CSCLI" >/dev/null; then | ||
PORT=$(cscli config show --key "Config.API.Server.ListenURI"|cut -d ":" -f2) | ||
if [ ! -z "$PORT" ]; then | ||
sed -i "s/localhost:8080/localhost:${PORT}/g" /etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml | ||
fi | ||
fi | ||
|
||
if [ ${START} -eq 0 ] ; then | ||
echo "no api key was generated, won't start service" | ||
else | ||
|
@@ -95,14 +103,6 @@ fi | |
* Tue Feb 16 2021 Manuel Sabban <[email protected]> | ||
- First initial packaging | ||
|
||
%preun -p /bin/bash | ||
|
||
if [ "$1" == "0" ] ; then | ||
systemctl stop crowdsec-firewall-bouncer || echo "cannot stop service" | ||
systemctl disable crowdsec-firewall-bouncer || echo "cannot disable service" | ||
fi | ||
|
||
|
||
|
||
|
||
%package -n crowdsec-firewall-bouncer-nftables | ||
|
@@ -120,11 +120,10 @@ Requires: nftables,gettext | |
systemctl daemon-reload | ||
|
||
START=0 | ||
CSCLI=/usr/bin/cscli | ||
|
||
if [ "$1" == "1" ] ; then | ||
type cscli > /dev/null | ||
|
||
if [ "$?" -eq "0" ] ; then | ||
if command -v "$CSCLI" >/dev/null; then | ||
START=1 | ||
echo "cscli/crowdsec is present, generating API key" | ||
unique=`date +%s` | ||
|
@@ -146,12 +145,26 @@ else | |
START=1 | ||
fi | ||
|
||
if command -v "$CSCLI" >/dev/null; then | ||
PORT=$(cscli config show --key "Config.API.Server.ListenURI"|cut -d ":" -f2) | ||
if [ ! -z "$PORT" ]; then | ||
sed -i "s/localhost:8080/localhost:${PORT}/g" /etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml | ||
fi | ||
fi | ||
|
||
if [ ${START} -eq 0 ] ; then | ||
echo "no api key was generated, won't start service" | ||
else | ||
systemctl start crowdsec-firewall-bouncer | ||
fi | ||
|
||
%preun -p /bin/bash | ||
|
||
if [ "$1" == "0" ] ; then | ||
systemctl stop crowdsec-firewall-bouncer || echo "cannot stop service" | ||
systemctl disable crowdsec-firewall-bouncer || echo "cannot disable service" | ||
fi | ||
|
||
%preun -p /bin/bash -n crowdsec-firewall-bouncer-nftables | ||
|
||
if [ "$1" == "0" ] ; then | ||
|
@@ -164,17 +177,11 @@ fi | |
|
||
if [ "$1" == "1" ] ; then | ||
systemctl restart crowdsec-firewall-bouncer || echo "cannot restart service" | ||
elif [ "$1" == "0" ] ; then | ||
systemctl stop crowdsec-firewall-bouncer | ||
systemctl disable crowdsec-firewall-bouncer | ||
fi | ||
|
||
|
||
%postun -p /bin/bash -n crowdsec-firewall-bouncer-nftables | ||
|
||
if [ "$1" == "1" ] ; then | ||
systemctl restart crowdsec-firewall-bouncer || echo "cannot restart service" | ||
elif [ "$1" == "0" ] ; then | ||
systemctl stop crowdsec-firewall-bouncer | ||
systemctl disable crowdsec-firewall-bouncer | ||
fi |