summaryrefslogtreecommitdiff
path: root/net-misc/gmid/files/gmid.initd
blob: a5f3b9f7eee16dad13c7f0245ab5c4d86952027c (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
#!/sbin/openrc-run
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

extra_commands="configtest"
extra_started_commands="reload"

description="Simple and secure Gemini server"
description_configtest="Run gmid's internal config check."
description_reload="Reload the gmid configuration without losing connections."

GMID_CONFIGFILE=${GMID_CONFIGFILE:-/etc/gmid/gmid.conf}

command="/usr/bin/gmid"
pidfile="/var/run/gmid.pid"
command_args="-c \"${GMID_CONFIGFILE}\" -P ${pidfile}"

depend() {
	need net
	use dns logger netmount
}

start_pre() {
	if [ "${RC_CMD}" != "restart" ]; then
		configtest || return 1
	fi
}

stop_pre() {
	if [ "${RC_CMD}" = "restart" ]; then
		configtest || return 1
	fi
}

reload() {
	configtest || return 1
	ebegin "Refreshing gmid's configuration"
	start-stop-daemon --signal SIGHUP --pidfile "${pidfile}"
	eend $? "Failed to reload gmid"
}

configtest() {
	ebegin "Checking gmid's configuration"
	${command} -c "${GMID_CONFIGFILE}" -n

	eend $? "failed, please correct errors in the config file"
}