aboutsummaryrefslogtreecommitdiff
path: root/textproc/sphinxsearch-devel/files/sphinxsearch.sh.in
blob: 877267aa363478443e12d8fe6a942cc64ec320e1 (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
79
80
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: %%PORTNAME%%
# REQUIRE: LOGIN
# KEYWORD: shutdown

#
# Add the following lines to /etc/rc.conf to enable %%PORTNAME%%:
#
# %%PORTNAME%%_enable="YES"
#
# Other rc.conf variables:
#
# %%PORTNAME%%_conffile="%%CFGFILE%%"
#                          -- path to config file
# %%PORTNAME%%_pidfile="%%SPHINX_RUN%%/searchd.pid"
#                          -- location of pidfile: must match setting
#                             in ${%%PORTNAME%%_conffile}
# %%PORTNAME%%_user="%%SPHINX_USR%%"
#                          -- user to run searchd as
# %%PORTNAME%%_group="%%SPHINX_GRP%%"
#                          -- group to run searchd as
# %%PORTNAME%%_logdir="%%SPHINX_LOG%%"
#                          -- directory searchd writes logs to
# %%PORTNAME%%_dir="%%SPHINX_DIR%%"
#                          -- working directory used by searchd et al:
#                             must match setting in ${%%PORTNAME%%_conffile}
#
. /etc/rc.subr

name=%%PORTNAME%%
rcvar=%%PORTNAME%%_enable

load_rc_config ${name}

: ${%%PORTNAME%%_enable="NO"}
: ${%%PORTNAME%%_conffile="%%CFGFILE%%"}
: ${%%PORTNAME%%_pidfile="%%SPHINX_RUN%%/searchd.pid"}
: ${%%PORTNAME%%_user="%%SPHINX_USR%%"}
: ${%%PORTNAME%%_group="%%SPHINX_GRP%%"}
: ${%%PORTNAME%%_logdir="%%SPHINX_LOG%%"}
: ${%%PORTNAME%%_dir="%%SPHINX_DIR%%"}

command=%%PREFIX%%/sbin/searchd
pidfile=${%%PORTNAME%%_pidfile}
required_files=${%%PORTNAME%%_conffile}
start_precmd=%%PORTNAME%%_prestart

%%PORTNAME%%_prestart ()
{
    piddir=$(dirname ${%%PORTNAME%%_pidfile})
    if [ ! -d ${piddir} ]; then
	mkdir -m 755 -p ${piddir}
	chown -R ${%%PORTNAME%%_user}:${%%PORTNAME%%_group} ${piddir}
    fi
    if [ ! -d ${%%PORTNAME%%_logdir} ]; then
	mkdir -m 755 -p ${%%PORTNAME%%_logdir}
	chown -R ${%%PORTNAME%%_user}:${%%PORTNAME%%_group} \
	    ${%%PORTNAME%%_logdir}
    fi
    if [ ! -d ${%%PORTNAME%%_dir} ]; then
        mkdir -m 755 -p ${%%PORTNAME%%_dir} ${%%PORTNAME%%_dir}/data
        chown -R ${%%PORTNAME%%_user}:${%%PORTNAME%%_group} \
            ${%%PORTNAME%%_dir}
    fi
}

case "${%%PORTNAME%%_flags}" in
    *--config\ *)
    echo "Warning \$%%PORTNAME%%_flags includes --config option." \
	"Please use \$%%PORTNAME%%_conffile instead."
    ;;
    *)
    %%PORTNAME%%_flags="--config ${%%PORTNAME%%_conffile} ${%%PORTNAME%%_flags}"
    ;;
esac

run_rc_command "$1"