summaryrefslogtreecommitdiff
path: root/net/pwhois/files/pwhoisd.in
blob: 4e810c16cd8289f335a3783583f9bbb8d41961b5 (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
#!/bin/sh

# PROVIDE: pwhoisd
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following line(s) to /etc/rc.conf to enable pwhoisd:
#
#  pwhoisd_enable="YES"
#

. /etc/rc.subr

name=pwhoisd
rcvar=pwhoisd_enable
load_rc_config $name

# Set defaults
pwhoisd_enable=${pwhoisd_enable:-"NO"}

_logdir=/var/log/pwhois
_dbdir=/var/db/pwhois
pidfile=/var/run/pwhoisd.pid
command=%%PREFIX%%/sbin/pwhoisd
command_args="-d -u 512 -g 512"
required_files=%%PREFIX%%/etc/pwhois/pwhoisd.conf

start_precmd=pwhoisd_precmd
stop_postcmd=pwhoisd_cleanup

pwhoisd_precmd()
{
    [ ! -f $pidfile ] && %%TOUCH%% $pidfile && %%CHOWN%% %%USER%%:%%GROUP%% $pidfile
    %%INSTALL%% -d -o %%USER%% -g %%GROUP%% $_dbdir
    %%INSTALL%% -d -o %%USER%% -g %%GROUP%% $_logdir
    return 0
}

pwhoisd_cleanup() {
    [ -f ${pidfile} ] && %%RM%% ${pidfile}
}

run_rc_command "$1"