aboutsummaryrefslogtreecommitdiffstats
path: root/unmaintained/mongodb/mongodb.initd
blob: 5b7b77eebf6b439ed944bdbd0745d24b023a253b (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
#!/sbin/runscript
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-db/mongodb/files/mongodb.initd,v 1.5 2013/01/18 11:19:27 ultrabug Exp $

depend() {
	need net
}

start() {
	checkpath -d -m 0750 -o "${MONGODB_USER}":mongodb "${MONGODB_RUN}"

	# Listen to MONGODB_IP if configured
	[ -z "${MONGODB_IP}" ] || MONGODB_OPTIONS="--bind_ip ${MONGODB_IP} ${MONGODB_OPTIONS}"

	# Baselayout-1 user should use --chuid instead of --user
	local USEROPT="--user"
	if [ ! -f /etc/init.d/sysfs ]; then
		USEROPT="--chuid"
	fi

	ebegin "Starting ${SVCNAME}"
	start-stop-daemon --background --start --make-pidfile \
		--pidfile ${MONGODB_RUN:-/var/run/mongodb}/${SVCNAME}.pid \
		${USEROPT} ${MONGODB_USER:-mongodb} \
		--exec ${MONGODB_EXEC:-/usr/bin/mongod} \
		-- \
		--port ${MONGODB_PORT:-27017} \
		--dbpath ${MONGODB_DATA:-/var/lib/mongodb} \
		--unixSocketPrefix ${MONGODB_RUN:-/var/run/mongodb} \
		--logappend --logpath /var/log/mongodb/${SVCNAME}.log \
		${MONGODB_OPTIONS}
	eend $?
}

stop() {
	ebegin "Stopping ${SVCNAME}"
	start-stop-daemon --stop --pidfile ${MONGODB_RUN:-/var/run/mongodb}/${SVCNAME}.pid
	eend $?
}