blob: 9b7765fbfd69a94cf9e9b0a60f87e052b3092828 (
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
#!/sbin/openrc-run
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
FCRON_INSTANCE="${SVCNAME##*.}"
if [ -n "${FCRON_INSTANCE}" ] && [ "${SVCNAME}" != "fcron" ]; then
FCRON_CONFIGFILE="/etc/fcron/fcron.${FCRON_INSTANCE}.conf"
else
FCRON_CONFIGFILE="/etc/fcron/fcron.conf"
fi
getconfig() {
local key="$1"
local value_default="$2"
local value=
if service_started; then
value="$(service_get_value "${key}")"
fi
if [ -z "${value}" ] && [ -r "${FCRON_CONFIGFILE}" ]; then
value="$(sed -n -e 's:^'"${key}"'[ \t]*=[ \t]*::p' "${FCRON_CONFIGFILE}")"
fi
if [ -z "${value}" ]; then
# Value not explicitly set in the configfile or configfile does not exist
# or is not readable
echo "${value_default}"
else
echo "${value}"
fi
return 0
}
depend() {
config "${FCRON_CONFIGFILE}"
use clock logger
need hostname
# provide the cron service if we are the main instance
[ "${SVCNAME}" = "fcron" ] && provide cron
}
command="/usr/libexec/fcron"
command_args="-c \"${FCRON_CONFIGFILE}\""
start_stop_daemon_args=${FCRON_SSDARGS:-"--wait 1000"}
pidfile="$(getconfig pidfile /run/fcron.pid)"
fcrontabs="$(getconfig fcrontabs /var/spool/fcron)"
fifofile="$(getconfig fifofile /run/fcron.fifo)"
required_files="${FCRON_CONFIGFILE}"
extra_started_commands="reload"
reload() {
start-stop-daemon --signal HUP --pidfile "${pidfile}"
}
start_pre() {
if [ "${SVCNAME}" != "fcron" ]; then
local _has_invalid_instance_cfg=0
if [ "${pidfile}" = "/run/fcron.pid" ]; then
eerror "You cannot use the same pidfile like the default instance!"
eerror "Please adjust your 'pidfile' setting in '${FCRON_CONFIGFILE}'."
_has_invalid_instance_cfg=1
fi
if [ "${fcrontabs}" = "/var/spool/fcron" ]; then
eerror "You cannot use the same fcrontabs location like the default instance!"
eerror "Please adjust your 'fcrontabs' setting in '${FCRON_CONFIGFILE}'."
_has_invalid_instance_cfg=1
fi
if [ "${fifofile}" = "/run/fcron.fifo" ]; then
eerror "You cannot use the same fifo file like the default instance!"
eerror "Please adjust your 'fifofile' setting in '${FCRON_CONFIGFILE}'."
_has_invalid_instance_cfg=1
fi
[ ${_has_invalid_instance_cfg} -ne 0 ] && return 1
fi
checkpath --file "${FCRON_CONFIGFILE}" --owner root:fcron --mode 0640
if [ ! -d "${fcrontabs}" ]; then
ebegin "Creating missing spooldir '${fcrontabs}'"
${command} --newspooldir "${fcrontabs}"
eend $?
fi
}
start_post() {
service_set_value fcrontabs "${fcrontabs}"
service_set_value fifofile "${fifofile}"
}
|