aboutsummaryrefslogtreecommitdiff
path: root/net/crowdsec-firewall-bouncer/Makefile
blob: 29a9251a678bc3500aa6ab241f22066e7139be86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# SPDX-License-Identifier: MIT
#
# Copyright (C) 2021 Gerald Kerma
#

include $(TOPDIR)/rules.mk

PKG_NAME:=crowdsec-firewall-bouncer
PKG_VERSION:=0.0.18
PKG_RELEASE:=$(AUTORELEASE)

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/crowdsecurity/cs-firewall-bouncer
PKG_MIRROR_HASH:=2fb7ddb226f6a99c46826706da25f7cdbcd7615468129e7b07f8ac4edf0366f9
PKG_SOURCE_VERSION:=v$(PKG_VERSION)
PKG_SOURCE_DATE:=20211210

PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=Gerald Kerma <gandalf@gk2.net>

PKG_BUILD_DEPENDS:=golang/host
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0

CSFB_BUILD_VERSION?=$(PKG_SOURCE_VERSION)
CSFB_BUILD_GOVERSION=$(shell go version | cut -d " " -f3 | sed -r 's/[go]+//g')
CWD_BUILD_TIMESTAMP:=$(SOURCE_DATE_EPOCH)
CSFB_BUILD_TAG=openwrt

CSFB_VERSION_PKG:=github.com/crowdsecurity/cs-firewall-bouncer/pkg/version

GO_PKG:=github.com/crowdsecurity/cs-firewall-bouncer

GO_PKG_LDFLAGS_X:=$(CSFB_VERSION_PKG).Version=$(CSFB_BUILD_VERSION) \
	$(CSFB_VERSION_PKG).BuildDate=$(CSFB_BUILD_TIMESTAMP) \
	$(CSFB_VERSION_PKG).Tag=$(CSFB_BUILD_TAG) \
	$(CSFB_VERSION_PKG).GoVersion=$(CSFB_BUILD_GOVERSION)

GO_PKG_INSTALL_ALL:=1

include $(INCLUDE_DIR)/package.mk
include ../../lang/golang/golang-package.mk

define Package/crowdsec-firewall-bouncer/Default
  SECTION:=net
  CATEGORY:=Network
  TITLE:=Firewall bouncer for Crowdsec
  URL:=https://github.com/crowdsecurity/cs-firewall-bouncer/
endef

define Package/crowdsec-firewall-bouncer
$(call Package/crowdsec-firewall-bouncer/Default)
  DEPENDS:=@(PACKAGE_iptables||PACKAGE_nftables) \
	$(GO_ARCH_DEPENDS)
endef

define Package/golang-crowdsec-firewall-bouncer-dev
$(call Package/crowdsec-firewall-bouncer/Default)
$(call GoPackage/GoSubMenu)
  TITLE+= (source files)
  DEPENDS:=$(GO_ARCH_DEPENDS)
  PKGARCH:=all
endef

define Package/crowdsec-firewall-bouncer/Default/description
  Crowdsec bouncer written in golang for firewalls.

  crowdsec-firewall-bouncer will fetch new and old decisions
  from a CrowdSec API to add them in a blocklist used by supported firewalls.

  You must install iptables+ipset or nftables.
endef

define Package/crowdsec-firewall-bouncer/description
$(call Package/crowdsec-firewall-bouncer/Default/description)

  This package contains the main program.
endef

define Package/golang-crowdsec-firewall-bouncer-dev/description
$(call Package/crowdsec-firewall-bouncer/Default/description)

  This package provides the source files for the program.
endef

define Package/crowdsec-firewall-bouncer/install
	$(call GoPackage/Package/Install/Bin,$(1))

	$(INSTALL_DIR) $(1)/etc/crowdsec/bouncers
	$(INSTALL_DATA) \
		$(GO_PKG_BUILD_DIR)/src/$(GO_PKG)/config/crowdsec-firewall-bouncer.yaml \
		$(1)/etc/crowdsec/bouncers

	$(INSTALL_DIR) $(1)/etc/init.d
	$(INSTALL_BIN) \
		./files/crowdsec-firewall-bouncer.initd \
		$(1)/etc/init.d/crowdsec-firewall-bouncer

	$(INSTALL_DIR) $(1)/etc
	$(INSTALL_BIN) \
		./files/crowdsec-firewall-bouncer.firewall \
		$(1)/etc/firewall.cs

	$(INSTALL_DIR) $(1)/etc/uci-defaults
	$(INSTALL_BIN) \
		./files/crowdsec-firewall-bouncer.defaults \
		$(1)/etc/uci-defaults/99_crowdsec-firewall-bouncer
endef

define Package/crowdsec-firewall-bouncer/conffiles
/etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml
endef

$(eval $(call GoBinPackage,crowdsec-firewall-bouncer))
$(eval $(call BuildPackage,crowdsec-firewall-bouncer))