Skip to content

Commit 6ae9ea0

Browse files
authored
deb: fixed bouncer removal when purging package (#60)
1 parent dc4dd9b commit 6ae9ea0

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

debian/postrm

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
set -eu
4+
5+
BOUNCER="crowdsec-custom-bouncer"
6+
CONFIG="/etc/crowdsec/bouncers/$BOUNCER.yaml"
7+
8+
if [ "$1" = "purge" ]; then
9+
if [ -f "$CONFIG.id" ]; then
10+
bouncer_id=$(cat "$CONFIG.id")
11+
cscli -oraw bouncers delete "$bouncer_id" 2>/dev/null || true
12+
rm -f "$CONFIG.id"
13+
fi
14+
fi

debian/prerm

+2-9
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,5 @@ set -eu
44

55
BOUNCER="crowdsec-custom-bouncer"
66

7-
#shellcheck source=./scripts/_bouncer.sh
8-
. "/usr/lib/$DPKG_MAINTSCRIPT_PACKAGE/_bouncer.sh"
9-
10-
systemctl stop "$SERVICE" || echo "cannot stop service"
11-
systemctl disable "$SERVICE" || echo "cannot disable service"
12-
13-
if [ "$1" = "purge" ]; then
14-
delete_bouncer
15-
fi
7+
systemctl stop "$BOUNCER" || echo "cannot stop service"
8+
systemctl disable "$BOUNCER" || echo "cannot disable service"

scripts/_bouncer.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ config_not_set() {
8989

9090
before=$(cat "$CONFIG")
9191
# shellcheck disable=SC2016
92-
after=$(envsubst '\$$varname' < "$CONFIG")
92+
after=$(envsubst "\$$varname" < "$CONFIG")
9393

9494
if [ "$before" = "$after" ]; then
9595
return 1
@@ -99,9 +99,9 @@ config_not_set() {
9999

100100
need_api_key() {
101101
if config_not_set 'API_KEY'; then
102-
return 1
102+
return 0
103103
fi
104-
return 0
104+
return 1
105105
}
106106

107107
# Interpolate a variable in the config file with a value.

0 commit comments

Comments
 (0)