blob: 26a74681bd424c89e9989fa4c2a945dadf2322c0 (
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
107
108
109
110
111
112
113
|
#!/bin/sh
# $FreeBSD$
#
# PROVIDE: memcached
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to run memcached:
#
# memcached_enable (bool): Set it to "YES" to enable memcached.
# Default is "NO".
# memcached_flags (flags): Set extra flags here. More options in memcached(1)
# Default is empty "".
# memcached_user (user): Set user to run memcached.
# Default is "nobody".
# memcached_profiles (str): Set to "" by default.
# Define your profiles here.
# memcached_post_start (str): Set extra commands that should be executed after memcached was successfully
# started here.
# Default is empty "".
. /etc/rc.subr
name="memcached"
rcvar=memcached_enable
_piddir="/var/run/memcached"
pidfile="${_piddir}/memcached.pid"
: ${memcached_enable="NO"}
: ${memcached_user="nobody"}
load_rc_config ${name}
if [ -n "$2" ]; then
profile="$2"
if [ -n "${memcached_profiles}" ]; then
pidfile="${_piddir}/memcached.${profile}.pid"
eval memcached_enable="\${memcached_${profile}_enable:-${memcached_enable}}"
eval memcached_user="\${memcached_${profile}_user:-${memcached_user}}"
eval memcached_flags="\${memcached_${profile}_flags:-${memcached_flags}}"
eval memcached_post_start="\${memcached_${profile}_post_start:-${memcached_post_start}}"
else
echo "%%PREFIX%%/etc/rc.d/memcached%%RC_SUBR_SUFFIX%%: extra argument ignored"
fi
else
if [ -n "${memcached_profiles}" -a -n "$1" ]; then
for profile in ${memcached_profiles}; do
eval _enable="\${memcached_${profile}_enable}"
case "${_enable:-${memcached_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=memcached_enable
else
_var=memcached_"${profile}"_enable
fi
warn "Bad value" \
"'${_enable:-${memcached_enable}}'" \
"for ${_var}. " \
"Profile ${profile} skipped."
continue
;;
esac
echo "===> memcached profile: ${profile}"
if %%PREFIX%%/etc/rc.d/memcached%%RC_SUBR_SUFFIX%% $1 ${profile} ; then
success="${profile} ${success:-}"
else
failed="${profile} (${retcode}) ${failed:-}"
fi
done
exit 0
fi
fi
memcached_poststart()
{
if [ -n "$memcached_post_start" ]; then
eval $memcached_post_start
fi
}
memcached_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
}
command=%%PREFIX%%/bin/memcached
command_args="-d -u ${memcached_user} -P ${pidfile} "
memcached_group=`id -gn $memcached_user`
start_precmd="install -d -o $memcached_user -g $memcached_group -m 755 $_piddir"
start_postcmd="${name}_poststart"
stop_postcmd="${name}_poststop"
run_rc_command "$1"
|