forked from toorop/banisher
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
115 additions
and
17 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 |
---|---|---|
|
@@ -11,4 +11,8 @@ | |
dist/banisher | ||
|
||
# Database | ||
dist/db.bdg | ||
dist/db.bdg | ||
|
||
# Packages | ||
dist/packages | ||
dist/*.deb |
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,10 +1,41 @@ | ||
version: '2' | ||
|
||
vars: | ||
GIT_VERSION: | ||
sh: git describe --tags --always | sed 's/v//g' | ||
|
||
tasks: | ||
|
||
build: | ||
cmds: | ||
- go build -o dist/banisher | ||
- go build -ldflags "-w -s -X main.appVersion={{.GIT_VERSION}}" -o dist/banisher | ||
|
||
run: | ||
deps: [build] | ||
cmds: | ||
- dist/banisher | ||
- dist/banisher | ||
|
||
package: | ||
deps: [build] | ||
vars: | ||
PACKAGE_BUILD_DATE: | ||
sh: date +%s | ||
cmds: | ||
- mkdir -p dist/packages/debian/DEBIAN | ||
- cp debian/postinst dist/packages/debian/DEBIAN/. | ||
- cp debian/prerm dist/packages/debian/DEBIAN/. | ||
- cp debian/control dist/packages/debian/DEBIAN/. | ||
- sed -i 's/#version#/{{.GIT_VERSION}}-{{.PACKAGE_BUILD_DATE}}/g' dist/packages/debian/DEBIAN/control | ||
- mkdir -p dist/packages/debian/lib/systemd/system | ||
- cp debian/banisher.service dist/packages/debian/lib/systemd/system/. | ||
- mkdir -p dist/packages/debian/usr/sbin | ||
- cp dist/banisher dist/packages/debian/usr/sbin/. | ||
- mkdir -p dist/packages/debian/etc | ||
- cp dist/config.yml dist/packages/debian/etc/banisher.yml | ||
- dpkg-deb --build dist/packages/debian dist/banisher_{{.GIT_VERSION}}-{{.PACKAGE_BUILD_DATE}}_amd64.deb | ||
|
||
clean: | ||
cmds: | ||
- rm dist/*.deb | ||
- rm dist/packages -R | ||
- rm dist/banisher |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[Unit] | ||
Description=The Banisher daemon | ||
After=network.target auditd.service | ||
|
||
[Service] | ||
ExecStartPre=/usr/bin/install -m 755 -o root -g root -d /var/lib/banisher | ||
ExecStart=/usr/sbin/banisher -conf=/etc/banisher.yml -db=/var/lib/banisher/db.bdg -systemd | ||
KillMode=process | ||
Restart=on-failure | ||
StandardOutput=syslog | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Package: banisher | ||
Version: #version# | ||
Section: net | ||
Priority: optional | ||
Architecture: amd64 | ||
Essential: no | ||
Maintainer: Olivier LARRIGAUDIERE | ||
Description: Watches your systemd journal and bans, with no delay, abusers. |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
. /usr/share/debconf/confmodule | ||
db_version 2.0 | ||
|
||
action="$1" | ||
oldversion="$2" | ||
|
||
umask 022 | ||
|
||
|
||
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then | ||
if [ -d /run/systemd/system ]; then | ||
systemctl --system daemon-reload >/dev/null || true | ||
if ! systemctl is-enabled banisher.service >/dev/null | ||
then | ||
systemctl enable banisher.service >/dev/null || true | ||
systemctl start banisher.service >/dev/null || true | ||
else | ||
systemctl restart banisher.service >/dev/null || true | ||
fi | ||
fi | ||
fi | ||
|
||
db_stop | ||
|
||
exit 0 |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
if [ -d /run/systemd/system ]; then | ||
deb-systemd-invoke stop banisher.service >/dev/null | ||
fi | ||
|
||
exit 0 |
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