aboutsummaryrefslogtreecommitdiffstats
path: root/testing/mongodb/mongos.initd
blob: a38fc50569af66da71c5e3fe05df0fd1ff9e64ab (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
#!/sbin/openrc-run
# 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/mongos.initd,v 1.3 2013/01/18 11:19:27 ultrabug Exp $

depend() {
	need net
}

checkconfig() {
	if [ -z "${MONGOS_CONFIGDB}" ]; then
		eerror "MONGOS_CONFIGDB is not defined, check your configuration file !"
		return 1
	fi
	return 0
}

start() {
	checkconfig || return 1

	checkpath -d -m 0750 -o "${MONGOS_USER}":mongodb "${MONGOS_RUN}"

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

	local USEROPT="--user"
	ebegin "Starting ${SVCNAME}"
	start-stop-daemon --background --start --make-pidfile \
		--pidfile ${MONGOS_RUN:-/var/run/mongodb}/${SVCNAME}.pid \
		${USEROPT} ${MONGOS_USER:-mongodb} \
		--exec ${MONGOS_EXEC:-/usr/bin/mongos} \
		-- \
		--port ${MONGOS_PORT:-27018} \
		--unixSocketPrefix ${MONGOS_RUN:-/var/run/mongodb} \
		--logappend --logpath /var/log/mongodb/${SVCNAME}.log \
		--configdb ${MONGOS_CONFIGDB} \
		${MONGOS_OPTIONS}
	eend $?
}

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