aboutsummaryrefslogtreecommitdiffstats
path: root/dns/credns/files/credns.in
blob: 98981586bff4310165ad3f6185b14f12b13f47ee (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
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: credns
# REQUIRE: DAEMON
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following line to /etc/rc.conf to enable credns
#
# credns_enable="YES"
#

. /etc/rc.subr

name=credns
rcvar=credns_enable

required_files=%%PREFIX%%/etc/credns/credns.conf

command=%%PREFIX%%/sbin/crednsc
command_args="start"
pidfile=`%%PREFIX%%/sbin/credns-checkconf -o pidfile %%PREFIX%%/etc/credns/credns.conf`
procname=%%PREFIX%%/sbin/${name}

load_rc_config ${name}

credns_enable=${credns_enable-"NO"}

extra_commands="reload"
start_precmd="credns_precmd"
reload_cmd="credns_reload"
stop_cmd="credns_stop"

credns_precmd()
{
    /usr/bin/install -d -o %%CREDNSUSER%% -g %%CREDNSGROUP%% %%CREDNSDBDIR%% %%CREDNSRUNDIR%%
    db=`%%PREFIX%%/sbin/credns-checkconf -o database %%PREFIX%%/etc/credns/credns.conf`
    if [ ! -f "$db" ]; then
        ${command} rebuild
    fi
}

credns_reload()
{
    ${command} rebuild && ${command} reload
}

credns_stop()
{
    echo "Merging credns zone transfer changes to zone files."
    ${command} patch

    echo "Stopping ${name}."
    ${command} stop
}

run_rc_command "$1"