summaryrefslogtreecommitdiff
path: root/app-text/groonga/files/groonga.initd
blob: a10516d4efda7a720500687ffa029f20ca36c3b8 (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
#!/sbin/openrc-run
# Copyright 1999-2026 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

command="/usr/bin/groonga"
pidfile="/run/${RC_SVCNAME}.pid"

# Groonga can't drop permissions on its own so there's no safe way to
# use the PID file that it would create if we started it as an
# unprivileged user and let it daemonize itself (and write its own PID
# file). Run it in "server" (i.e. foreground) mode instead, and have
# OpenRC background it and manage its PID file.
command_args="-s
	--config-path=${GROONGA_CONFIG:-/etc/groonga/groonga.conf}
	${GROONGA_DATABASE}"
command_user="${GROONGA_USER:-groonga}:${GROONGA_GROUP:-groonga}"
command_background="true"

depend() {
	use net
}

start_pre() {
	if  [ ! -e "${GROONGA_DATABASE}" ] ; then
		einfo "Creating database ${GROONGA_DATABASE}"
		su -s /bin/sh -c "${command} -n ${GROONGA_DATABASE} quit" ${GROONGA_USER:-groonga}
	fi
}