diff --git a/security/crowdsec/Makefile b/security/crowdsec/Makefile index df0fb1ec1e06..9a6aa7ada379 100644 --- a/security/crowdsec/Makefile +++ b/security/crowdsec/Makefile @@ -1,28 +1,45 @@ PORTNAME= crowdsec -PORTVERSION= 1.0.13 +PORTVERSION= 1.1.1 DISTVERSIONPREFIX= v CATEGORIES= security MAINTAINER= sbz@FreeBSD.org COMMENT= Crowdsec lightweight and collaborative security engine LICENSE= MIT 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 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 @@ -1,47 +1,61 @@ #!/bin/sh # PROVIDE: crowdsec # REQUIRE: LOGIN DAEMON NETWORKING # KEYWORD: shutdown # # Add the following lines to /etc/rc.conf.local or /etc/rc.conf # to enable this service: # # crowdsec_enable (bool): Set it to YES to enable crowdsec agent. # Default is "NO". # crowdsec_config (str): Set the agent config path. # Default is "%%PREFIX%%/etc/crowdsec/config.yaml". # crowdsec_flags (str): Set the extra flags to run agent. # Default is "" . /etc/rc.subr name=crowdsec desc="Crowdsec Agent" rcvar=crowdsec_enable load_rc_config $name : ${crowdsec_enable:="NO"} : ${crowdsec_config:="%%PREFIX%%/etc/crowdsec/config.yaml"} : ${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}" \ ${command} -c ${crowdsec_config} ${crowdsec_flags} } crowdsec_configtest() { echo "Performing sanity check on ${name} configuration." eval ${command} -c ${crowdsec_config} -t } run_rc_command "$1" 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: <