Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Jul 2021 14:20:13 GMT
From:      Sofian Brabez <sbz@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: 337d0e23c1fa - main - security/crowdsec: update to 1.1.1
Message-ID:  <202107141420.16EEKDTX049742@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by sbz:

URL: https://cgit.FreeBSD.org/ports/commit/?id=337d0e23c1fac63b3d235bd3171c4d00ce8c810c

commit 337d0e23c1fac63b3d235bd3171c4d00ce8c810c
Author:     Sofian Brabez <sbz@FreeBSD.org>
AuthorDate: 2021-07-14 14:07:31 +0000
Commit:     Sofian Brabez <sbz@FreeBSD.org>
CommitDate: 2021-07-14 14:09:23 +0000

    security/crowdsec: update to 1.1.1
---
 security/crowdsec/Makefile             | 29 +++++++++++++++++++++------
 security/crowdsec/distinfo             | 10 +++++-----
 security/crowdsec/files/crowdsec.in    | 14 +++++++++++++
 security/crowdsec/files/pkg-message.in | 13 ++++++++++++
 security/crowdsec/pkg-plist            | 36 ++++++++++++++++++++++++++++++++++
 5 files changed, 91 insertions(+), 11 deletions(-)

diff --git a/security/crowdsec/Makefile b/security/crowdsec/Makefile
index df0fb1ec1e06..9a6aa7ada379 100644
--- a/security/crowdsec/Makefile
+++ b/security/crowdsec/Makefile
@@ -1,5 +1,5 @@
 PORTNAME=	crowdsec
-PORTVERSION=	1.0.13
+PORTVERSION=	1.1.1
 DISTVERSIONPREFIX=	v
 CATEGORIES=	security
 
@@ -11,18 +11,35 @@ LICENSE_FILE=	${WRKSRC}/LICENSE
 
 USES=		go:modules
 
+USE_RC_SUBR=	crowdsec
+
 GO_MODULE=	github.com/crowdsecurity/crowdsec
 
 GO_BUILDFLAGS=	-ldflags "-s -w \
-		-X github.com/crowdsecurity/crowdsec/pkg/cwversion.Version=v${PORTVERSION}\
-		-X github.com/crowdsecurity/crowdsec/pkg/cwversion.System=freebsd"
+		-X github.com/crowdsecurity/crowdsec/pkg/cwversion.Version=v${PORTVERSION} \
+		-X github.com/crowdsecurity/crowdsec/pkg/cwversion.System=freebsd \
+		-X github.com/crowdsecurity/crowdsec/pkg/cwversion.BuildDate=`date -u '+%Y-%m-%d_%I:%M:%S%p'`"
 
 GO_TARGET=	./cmd/crowdsec \
 		./cmd/crowdsec-cli
 
-USE_RC_SUBR=	crowdsec
+SUB_FILES=	pkg-message
+
+post-patch:
+	@${REINPLACE_CMD} 's,/etc/crowdsec/,${ETCDIR}/,g' \
+		${WRKSRC}/pkg/csconfig/config.go \
+		${WRKSRC}/cmd/crowdsec-cli/machines.go \
+		${WRKSRC}/cmd/crowdsec-cli/main.go \
+		${WRKSRC}/cmd/crowdsec/main.go
+
+do-install:
+	@${MKDIR} ${STAGEDIR}${ETCDIR}
+	@(cd ${WRKSRC}/config && ${COPYTREE_SHARE} . ${STAGEDIR}${ETCDIR})
+
+	@${MV} ${STAGEDIR}${ETCDIR}/config.yaml \
+		${STAGEDIR}${ETCDIR}/config.yaml.sample
 
-PLIST_FILES=	bin/crowdsec \
-		bin/crowdsec-cli
+	${INSTALL_PROGRAM} ${WRKDIR}/bin/crowdsec ${STAGEDIR}${PREFIX}/bin
+	${INSTALL_PROGRAM} ${WRKDIR}/bin/crowdsec-cli ${STAGEDIR}${PREFIX}/bin
 
 .include <bsd.port.mk>
diff --git a/security/crowdsec/distinfo b/security/crowdsec/distinfo
index aa4793d1a6c3..2d309c313933 100644
--- a/security/crowdsec/distinfo
+++ b/security/crowdsec/distinfo
@@ -1,5 +1,5 @@
-TIMESTAMP = 1620115762
-SHA256 (go/security_crowdsec/crowdsec-v1.0.13/v1.0.13.mod) = e751afda0503bcfe8589775002b1fc1bd7271d603d56aa47d18ed5b3187e15c6
-SIZE (go/security_crowdsec/crowdsec-v1.0.13/v1.0.13.mod) = 3203
-SHA256 (go/security_crowdsec/crowdsec-v1.0.13/v1.0.13.zip) = 6f94f690ef87d7cfd3befe28129fd3a3014b50d81f78259d364f2ede8605a25a
-SIZE (go/security_crowdsec/crowdsec-v1.0.13/v1.0.13.zip) = 41998630
+TIMESTAMP = 1626257804
+SHA256 (go/security_crowdsec/crowdsec-v1.1.1/v1.1.1.mod) = f764f7d850f1e2306f6764e534ace7261f7dc99f3b4884c2b0f617cb791b35de
+SIZE (go/security_crowdsec/crowdsec-v1.1.1/v1.1.1.mod) = 3295
+SHA256 (go/security_crowdsec/crowdsec-v1.1.1/v1.1.1.zip) = f7e63641a67392d57412ab1ff86a26ae4deeb9fc8460542f6258f7c9f56238e9
+SIZE (go/security_crowdsec/crowdsec-v1.1.1/v1.1.1.zip) = 640252
diff --git a/security/crowdsec/files/crowdsec.in b/security/crowdsec/files/crowdsec.in
index 9efe8305857b..59219b42aa19 100644
--- a/security/crowdsec/files/crowdsec.in
+++ b/security/crowdsec/files/crowdsec.in
@@ -27,11 +27,25 @@ load_rc_config $name
 : ${crowdsec_flags:=""}
 
 pidfile=/var/run/${name}.pid
+required_files="$crowdsec_config"
 command="%%PREFIX%%/bin/${name}"
 start_cmd="${name}_start"
+start_precmd="${name}_precmd"
 configtest_cmd="${name}_configtest"
 extra_commands="configtest reload"
 
+crowdsec_precmd() {
+    if [ ! -d %%PREFIX%%/etc/crowdsec/hub ]; then
+        %%PREFIX%%/bin/crowdsec-cli hub update || :
+    fi
+    if [ -z "`%%PREFIX%%/bin/crowdsec-cli machines list -o raw`" ]; then
+        %%PREFIX%%/bin/crowdsec-cli machines add --auto || :
+    fi
+    if [ ! -s %%PREFIX%%/etc/crowdsec/online_api_credentials.yaml ]; then
+        %%PREFIX%%/bin/crowdsec-cli capi register || :
+    fi
+}
+
 crowdsec_start()
 {
 	/usr/sbin/daemon -f -p ${pidfile} -t "${desc}" \
diff --git a/security/crowdsec/files/pkg-message.in b/security/crowdsec/files/pkg-message.in
new file mode 100644
index 000000000000..93da4e2c4dae
--- /dev/null
+++ b/security/crowdsec/files/pkg-message.in
@@ -0,0 +1,13 @@
+[
+{ type: install
+  message: <<EOM
+
+crowdsec is installed.
+
+You need to edit the agent config file %%ETCDIR%%/crowdsec.yaml and
+enable rc via sysrc.
+
+# sysrc crowdsec_enable="YES"
+EOM
+}
+]
diff --git a/security/crowdsec/pkg-plist b/security/crowdsec/pkg-plist
new file mode 100644
index 000000000000..b3555470e374
--- /dev/null
+++ b/security/crowdsec/pkg-plist
@@ -0,0 +1,36 @@
+@sample %%ETCDIR%%/config.yaml.sample
+bin/crowdsec
+bin/crowdsec-cli
+%%ETCDIR%%/acquis.yaml
+%%ETCDIR%%/crowdsec.service
+%%ETCDIR%%/crowdsec_pull
+%%ETCDIR%%/dev.yaml
+%%ETCDIR%%/local_api_credentials.yaml
+%%ETCDIR%%/online_api_credentials.yaml
+%%ETCDIR%%/patterns/aws
+%%ETCDIR%%/patterns/bacula
+%%ETCDIR%%/patterns/bro
+%%ETCDIR%%/patterns/cowrie_honeypot
+%%ETCDIR%%/patterns/exim
+%%ETCDIR%%/patterns/firewalls
+%%ETCDIR%%/patterns/haproxy
+%%ETCDIR%%/patterns/java
+%%ETCDIR%%/patterns/junos
+%%ETCDIR%%/patterns/linux-syslog
+%%ETCDIR%%/patterns/mcollective
+%%ETCDIR%%/patterns/modsecurity
+%%ETCDIR%%/patterns/mongodb
+%%ETCDIR%%/patterns/mysql
+%%ETCDIR%%/patterns/nagios
+%%ETCDIR%%/patterns/nginx
+%%ETCDIR%%/patterns/paths
+%%ETCDIR%%/patterns/postgresql
+%%ETCDIR%%/patterns/rails
+%%ETCDIR%%/patterns/redis
+%%ETCDIR%%/patterns/ruby
+%%ETCDIR%%/patterns/smb
+%%ETCDIR%%/patterns/ssh
+%%ETCDIR%%/patterns/tcpdump
+%%ETCDIR%%/profiles.yaml
+%%ETCDIR%%/simulation.yaml
+%%ETCDIR%%/user.yaml



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107141420.16EEKDTX049742>