summaryrefslogtreecommitdiff
path: root/net-mgmt/p0f2/files/p0f2.in
blob: 620643e3cef1a4db15f66256c25839fbcef5502b (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
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
#!/bin/sh

# $FreeBSD$
#
# PROVIDE: p0f2
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# p0f_enable (bool):	Set to NO by default.
#
# p0f_user:		User to drop privileges and change to
#
# p0f_int:		Network interface to listen on
#
# p0f_sock (path):	Path to socket used to communicate with p0f
#
# p0f_args:		Additonal options passed to the p0f daemon
#
# p0f_log (path):	File where p0f logs matches
#
# p0f_db (path):	Location of fingerprint db. 
#			Defaults to %%PREFIX%%/p0f/p0f.fp

. /etc/rc.subr

name="p0f"
rcvar=p0f_enable

load_rc_config ${name}

: ${p0f_enable:="NO"}
: ${p0f_user:="root"}
: ${p0f_sock:="/var/run/${name}.sock"}
: ${p0f_log:="/var/log/p0f.log"}
: ${p0f_db:="%%PREFIX%%/etc/p0f/p0f.fp"}

stop_cmd="${name}_stopcmd"
status_cmd="${name}_statuscmd"

pidfile=/var/run/${name}.pid
p0f_command="%%PREFIX%%/bin/${name} -i ${p0f_int} -u ${p0f_user} -Q ${p0f_sock} -o ${p0f_log} -f ${p0f_db} ${p0f_args}"
command="/usr/sbin/daemon"
command_args="-f -p ${pidfile} ${p0f_command}"

p0f_statuscmd()
{
	if [ ! -e $pidfile ];
	then
		echo "pidfile does not exist. $name is not running?";
		exit 1;
	fi

	if pgrep -F $pidfile >/dev/null;
	then
		echo "$name is running.";
	else
		echo "$name is not running.";
		exit 1;
	fi
}

p0f_stopcmd()
{
	if pgrep -F $pidfile >/dev/null; 
	then
		p0fpid=`cat $pidfile`;
		kill $sig_stop ${p0fpid};
		wait_for_pids ${p0fpid};
	else
		echo "$name is not running.";
		exit 1;
	fi
}

run_rc_command "$1"