aboutsummaryrefslogtreecommitdiff
path: root/security/crowdsec/files/crowdsec.in
blob: 5c2c632de170b37e8dc6f3d9411c5e4bd98f1866 (plain) (blame)
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
#!/bin/sh

# $FreeBSD$
#
# 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
command="%%PREFIX%%/bin/${name}"
start_cmd="${name}_start"
configtest_cmd="${name}_configtest"
extra_commands="configtest reload"

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"