summaryrefslogtreecommitdiff
path: root/security/zeek/files/zeek.in
blob: 9dec41360f26d56f6c3ee11f9d856c6c869037dc (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
#!/bin/sh

# PROVIDE: zeek
# REQUIRE: NETWORKING
# REQUIRE: LOGIN FILESYSTEMS
# KEYWORD: shutdown

. /etc/rc.subr

name="zeek"
rcvar=`set_rcvar`
node=$2

start_cmd="zeek_start"
stop_cmd="zeek_stop"
restart_cmd="zeek_restart"
check_cmd="zeek_check"
deploy_cmd="zeek_deploy"
install_cmd="zeek_install"
cleanup_cmd="zeek_cleanup"
restart_cmd="zeek_restart"
status_cmd="zeek_status"

extra_commands="check cleanup deploy install restart status"

: ${zeekctl_program:=%%PREFIX%%/bin/zeekctl}
: ${zeek_user:=root}

zeek_enable=${zeek_enable-"NO"}

run()
{
	if [ "${zeek_user}" = "root" ]; then
		$*
	else
		su -m ${zeek_user} -c "$*"
	fi
}

zeek_start()
{
	if [ ! "${node}" ]; then
		run ${zeekctl_program} start
	else
		run ${zeekctl_program} start ${node}
	fi
}

zeek_stop()
{
	if [ ! "${node}" ]; then
		run ${zeekctl_program} stop
	else
		run ${zeekctl_program} stop ${node}
	fi
}

zeek_restart() {
	if [ ! "${node}" ]; then
		run ${zeekctl_program} restart
	else
		run ${zeekctl_program} restart ${node}
	fi
}

zeek_check()
{
	run ${zeekctl_program} check
}

zeek_deploy()
{
	run ${zeekctl_program} deploy
}

zeek_install()
{
	run ${zeekctl_program} install
}

zeek_cleanup()
{
	if [ ! "${node}" ]; then
		run ${zeekctl_program} cleanup
	else
		run ${zeekctl_program} cleanup ${node}
	fi
}

zeek_status()
{
	run ${zeekctl_program} status
}

load_rc_config ${name}
run_rc_command "$1"