-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated packaging, tests and CI (#59)
- Loading branch information
Showing
20 changed files
with
490 additions
and
278 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
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
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
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
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
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
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
crowdsec-custom-bouncer (1.0.0) UNRELEASED; urgency=medium | ||
|
||
* Initial debian packaging | ||
-- Shivam Sandbhor <shivam@crowdsec.net> Mon Jun 28 10:52:32 2021 +0530 | ||
|
||
-- Shivam Sandbhor <shivam@crowdsec.net> Mon, 28 Jun 2021 10:52:32 +0530 |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
Source: crowdsec-custom-bouncer | ||
Maintainer: Crowdsec Team <debian@crowdsec.net> | ||
Build-Depends: debhelper, bash | ||
Build-Depends: debhelper | ||
Section: admin | ||
Priority: optional | ||
|
||
Package: crowdsec-custom-bouncer | ||
Provides: crowdsec-custom-bouncer | ||
Depends: gettext-base | ||
Description: Custom bouncer for Crowdsec | ||
Architecture: any | ||
|
||
|
||
|
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 |
---|---|---|
@@ -1,38 +1,28 @@ | ||
#!/bin/sh | ||
|
||
systemctl daemon-reload | ||
|
||
BOUNCER="crowdsec-custom-bouncer" | ||
BOUNCER_PREFIX="CustomBouncer" | ||
|
||
START=0 | ||
#shellcheck source=./scripts/_bouncer.sh | ||
. "/usr/lib/$DPKG_MAINTSCRIPT_PACKAGE/_bouncer.sh" | ||
START=1 | ||
|
||
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." | ||
if [ "$1" = "configure" ]; then | ||
if need_api_key; then | ||
if ! set_api_key; then | ||
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 | ||
|
||
systemctl --quiet is-enabled "$SERVICE" || systemctl unmask "$SERVICE" && systemctl enable "$SERVICE" | ||
|
||
set_local_lapi_url 'CROWDSEC_LAPI_URL' | ||
|
||
if [ ${START} -eq 0 ] ; then | ||
echo "no api key was generated" | ||
if [ "$START" -eq 0 ]; then | ||
echo "no api key was generated, you can generate one on your LAPI server by running 'cscli bouncers add <bouncer_name>' and add it to '$CONFIG'" >&2 | ||
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' " | ||
echo "please enter the binary path in '$CONFIG' and start the bouncer via 'sudo systemctl start $SERVICE'" |
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 |
---|---|---|
@@ -1,2 +1,15 @@ | ||
systemctl stop crowdsec-custom-bouncer || echo "cannot stop service" | ||
systemctl disable crowdsec-custom-bouncer || echo "cannot disable service" | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
BOUNCER="crowdsec-custom-bouncer" | ||
|
||
#shellcheck source=./scripts/_bouncer.sh | ||
. "/usr/lib/$DPKG_MAINTSCRIPT_PACKAGE/_bouncer.sh" | ||
|
||
systemctl stop "$SERVICE" || echo "cannot stop service" | ||
systemctl disable "$SERVICE" || echo "cannot disable service" | ||
|
||
if [ "$1" = "purge" ]; then | ||
delete_bouncer | ||
fi |
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
Oops, something went wrong.