aboutsummaryrefslogtreecommitdiffstats
path: root/databases/cyrus-smlacapd/files/cyrus_smlacapd_backend.sh.in
blob: 2e82d62f686e29d4174370c60e242645ed34c6a4 (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
#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE: cyrus_smlacapd_backend
# REQUIRE: DAEMON cyrus_pwcheck
# KEYWORD: FreeBSD shutdown

#
# Add the following line to /etc/rc.conf to enable cyrus_smlacapd_backend:
# cyrus_smlacapd_backend_enable="YES"
#
prefix=%%PREFIX%%
cyrus=${prefix}/cyrus
. %%RC_SUBR$$

name="cyrus_smlacapd_backend"
rcvar=`set_rcvar`

[ -z "$cyrus_smlacapd_backend_enable" ] && cyrus_smlacapd_backend_enable="NO"
[ -z "$cyrus_smlacapd_backend_runtime" ]    && cyrus_smlacapd_backend_runtime="${cyrus}/bin/run.x86-freebsd"
[ -z "$cyrus_smlacapd_backend_heap" ]   && cyrus_smlacapd_backend_heap="${cyrus}bin/backend.x86-bsd"

required_dirs="/var/acap /var/spool/acap"
pidfile=/var/run/cyrus_smlacapd_backend.pid
procname=$cyrus_smlacapd_backend_runtime
start_precmd="cyrus_smlacapd_backend_precmd"
start_postcmd="cyrus_smlacapd_backend_postcmd"
command=/usr/sbin/daemon
command_args="-f $cyrus_smlacapd_backend_runtime @SMLload=$cyrus_smlacapd_backend_heap"

cyrus_smlacapd_backend_precmd()
{
    SOCKET=/var/acap/socke
    if [ -e ${SOCKET} ]
    then
        rm ${SOCKET}
    fi
}

cyrus_smlacapd_backend_postcmd()
{
    sleep 1
    pid=`ps -o pid,command -axww | \
         awk '$2 == "'$cyrus_smlacapd_backend_runtime'" && $3 == "@SMLload='$cyrus_smlacapd_backend_heap'" { print $1 }'`
    if [ -n "$pid" ]
    then
        echo "$pid" > $pidfile
    fi
}

load_rc_config $name

run_rc_command "$1"