blob: 7c21d27fff3ee22763988a6dbb73938b9baf15f9 (
plain)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: beanstalkd
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to run beanstalkd:
#
# beanstalkd_enable (bool): Set it to "YES" to enable beanstalkd.
# Default is "NO".
# beanstalkd_flags (flags): Set extra flags here. More options in beanstalkd(1)
# Default is empty "".
# beanstalkd_user (user): Set user to run beanstalkd.
# Default is "nobody".
# beanstalkd_profiles (str): Set to "" by default.
# Define your profiles here.
. /etc/rc.subr
name="beanstalkd"
rcvar=beanstalkd_enable
_piddir="/var/run/beanstalkd"
pidfile="${_piddir}/beanstalkd.pid"
load_rc_config ${name}
if [ -n "$2" ]; then
profile="$2"
if [ -n "${beanstalkd_profiles}" ]; then
pidfile="${_piddir}/beanstalkd.${profile}.pid"
eval beanstalkd_enable="\${beanstalkd_${profile}_enable:-${beanstalkd_enable}}"
eval beanstalkd_flags="\${beanstalkd_${profile}_flags:-${beanstalkd_flags}}"
else
echo "%%PREFIX%%/etc/rc.d/beanstalkd%%RC_SUBR_SUFFIX%%: extra argument ignored"
fi
else
if [ -n "${beanstalkd_profiles}" -a -n "$1" ]; then
for profile in ${beanstalkd_profiles}; do
eval _enable="\${beanstalkd_${profile}_enable}"
case "${_enable:-${beanstalkd_enable}}" in
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
continue
;;
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
;;
*)
if test -z "$_enable"; then
_var=beanstalkd_enable
else
_var=beanstalkd_"${profile}"_enable
fi
warn "Bad value" \
"'${_enable:-${beanstalkd_enable}}'" \
"for ${_var}. " \
"Profile ${profile} skipped."
continue
;;
esac
echo "===> beanstalkd profile: ${profile}"
if %%PREFIX%%/etc/rc.d/beanstalkd%%RC_SUBR_SUFFIX%% $1 ${profile} ; then
success="${profile} ${success:-}"
else
failed="${profile} (${retcode}) ${failed:-}"
fi
done
exit 0
fi
fi
beanstalkd_poststop()
{
if [ -n "${profile}" ]; then
[ -e "$pidfile" ] && unlink $pidfile
else
local file
for file in ${_piddir}/* ; do
case "$file" in
*\*)
continue ;;
esac
unlink $file
done
fi
}
beanstalkd_prestart()
{
install -d -o $beanstalkd_user -g $beanstalkd_user -m 755 $_piddir
}
: ${beanstalkd_enable="NO"}
: ${beanstalkd_user="nobody"}
procname=%%PREFIX%%/bin/beanstalkd
command="/usr/sbin/daemon"
command_args="-p ${pidfile} ${procname} ${beanstalkd_flags}"
unset beanstalkd_flags
start_precmd="${name}_prestart"
stop_postcmd="${name}_poststop"
run_rc_command "$1"
|