aboutsummaryrefslogtreecommitdiffstats
path: root/testing/gmid/gmid.initd
blob: 6ff1812f1dce8134857b01fbf6e2fd72b168b8ab (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
#!/sbin/openrc-run
# Copyright 1999-2021 Gentoo Authors
# Copyright 2021 Maxim Karasev <begs@disroot.org>
# Distributed under the terms of the GNU General Public License v2

extra_commands="configtest"
extra_started_commands="reload"

name="gmid"
description="Simple and secure Gemini server"
description_configtest="Run gmid's internal config check."
description_reload="Reload the gmid configuration without losing connections."
supervisor=supervise-daemon
command=/usr/bin/gmid
command_args="-c \"$gmid_config_file\" -P \"$gmid_pid_file\" -f"

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 --pid "$gmid_pid_file"
	eend $? "Failed to reload gmid"
}

configtest() {
	ebegin "Checking gmid's configuration"
	${command} -c "${gmid_config_file}" -n
	eend $? "failed, please correct errors in the config file"
}