blob: 408405c42a28a702ae15ce0b6aeec2e258ce3476 (
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
48
49
50
51
52
53
|
#!/sbin/openrc-run
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
extra_commands="checkconfig"
extra_started_commands="reload"
description="Caddy web server"
pidfile=${pidfile:-"/run/${RC_SVCNAME}.pid"}
command="/usr/bin/caddy"
command_user="${command_user:-"http:http"}"
caddy_config="${caddy_config:-"/etc/caddy/Caddyfile"}"
command_args="${command_args:-"run --config ${caddy_config}"}"
command_background="true"
logfile="${logfile:-"/var/log/${RC_SVCNAME}/${RC_SVCNAME}.log"}"
start_stop_daemon_args="--user ${command_user%:*} --group ${command_user#*:}
--stdout ${logfile} --stderr ${logfile}"
: "${supervisor:=supervise-daemon}"
: "${respawn_delay:=5}"
: "${respawn_max:=10}"
: "${respawn_period:=60}"
depend() {
need net
}
checkconfig() {
if [ ! -f "${caddy_config}" ] ; then
ewarn "${caddy_config} does not exist."
return 1
fi
"${command}" validate --config "${caddy_config}" >> "${logfile}" 2>&1
}
start() {
checkconfig || { eerror "Invalid configuration file !" && return 1; }
checkpath --directory --mode 755 --owner root "${pidfile%/*}"
checkpath --directory --mode 755 --owner "${command_user}" "${logfile%/*}"
default_start
}
reload() {
if ! service_started "${SVCNAME}" ; then
eerror "${SVCNAME} isn't running"
return 1
fi
checkconfig || { eerror "Invalid configuration file !" && return 1; }
ebegin "Reloading ${SVCNAME}"
"${command}" reload --force --config "${caddy_config}" > /dev/null 2>&1
eend $?
}
|