blob: a7d1d3833bbb36b0de7392418cb69cf2515ce910 (
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
|
#!/bin/sh
# PROVIDE: mongod
# REQUIRE: NETWORK ldconfig
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# mongod_enable (bool): Set to "NO" by default.
# Set it to "YES" to enable mongod.
# mongod_limits (bool): Set to "NO" by default.
# Set it to yes to run `limits -e -U mongodb`
# just before mongod starts.
# mongod_dbpath (str): Default to "/var/db/mongodb"
# Base database directory.
# mongod_flags (str): Custom additional arguments to be passed to mongod.
# Default to "--logpath /var/log/mongodb/mongod.log --logappend".
# mongod_config (str): Default to "%%PREFIX%%/etc/mongodb.conf"
# Path to config file
#
. /etc/rc.subr
name="mongod"
rcvar=mongod_enable
load_rc_config $name
: ${mongod_enable="NO"}
: ${mongod_limits="NO"}
: ${mongod_dbpath="/var/db/mongodb"}
: ${mongod_logpath="/var/log/mongodb"}
: ${mongod_runpath="/var/run/mongodb"}
: ${mongod_flags="--logpath ${mongod_logpath}/mongod.log --logappend"}
: ${mongod_user="mongodb"}
: ${mongod_group="mongodb"}
: ${mongod_config="%%PREFIX%%/etc/mongod.conf"}
pidfile="${mongod_runpath}/mongod.pid"
command=%%PREFIX%%/bin/${name}
command_args="--config $mongod_config --dbpath $mongod_dbpath --fork >/dev/null 2>/dev/null"
start_precmd="${name}_prestart"
mongod_create_dbpath()
{
install -d -g ${mongod_group} -o ${mongod_user} -m 755 ${mongod_dbpath}
install -d -g ${mongod_group} -o ${mongod_user} -m 755 ${mongod_logpath}
install -d -g ${mongod_group} -o ${mongod_user} -m 755 ${mongod_runpath}
}
mongod_prestart()
{
if [ ! -d ${mongod_dbpath} -o ! -d ${mongod_logpath} ]; then
mongod_create_dbpath || return 1
fi
if checkyesno mongod_limits; then
eval `/usr/bin/limits -e -U ${mongod_user}` 2>/dev/null
else
return 0
fi
}
run_rc_command "$1"
|