diff options
author | zlg <zlg@zlg.space> | 2018-11-19 13:34:21 -0800 |
---|---|---|
committer | zlg <zlg@zlg.space> | 2018-11-19 14:05:19 -0800 |
commit | 804750211eca2d372cacf2f04eab2ce3183c1101 (patch) | |
tree | 0ea01012d05f64cec14b1e732a65712c8c1d3cf5 /system/fcron/fcron.initd | |
parent | 3a06f7cc492260836cd9910e2509aec9f0ba3d54 (diff) | |
download | packages-804750211eca2d372cacf2f04eab2ce3183c1101.tar.gz packages-804750211eca2d372cacf2f04eab2ce3183c1101.tar.bz2 packages-804750211eca2d372cacf2f04eab2ce3183c1101.tar.xz packages-804750211eca2d372cacf2f04eab2ce3183c1101.zip |
system/fcron: fix initd '[crashed]' message
Importing Gentoo's fcron initd script brings more options to starting
fcron and fixes the '[crashed]' message in `rc-status`.
Diffstat (limited to 'system/fcron/fcron.initd')
-rwxr-xr-x | system/fcron/fcron.initd | 103 |
1 files changed, 94 insertions, 9 deletions
diff --git a/system/fcron/fcron.initd b/system/fcron/fcron.initd index ff0aba09c..8727468bf 100755 --- a/system/fcron/fcron.initd +++ b/system/fcron/fcron.initd @@ -1,15 +1,100 @@ #!/sbin/openrc-run - -# Initscript by Diaz Devera Victor <vitronic2@gmail.com> -# Copyright 2014 Alpine Linux +# Copyright 1999-2017 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -#name="advanced periodic command scheduler fcron" -name="fcron" -pidfile="/run/fcron" -command=/usr/sbin/fcron +FCRON_INSTANCE="${SVCNAME##*.}" +FCRON_OPTS=${FCRON_OPTS:-""} + +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() { - need localmount - need logger + config "${FCRON_CONFIGFILE}" + + use clock logger + need hostname + + # provide the cron service if we are the main instance + [ "${SVCNAME}" = "fcron" ] && provide cron +} + + +command="/usr/sbin/fcron" +command_args="${FCRON_OPTS} -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}" } |