From 804750211eca2d372cacf2f04eab2ce3183c1101 Mon Sep 17 00:00:00 2001 From: zlg Date: Mon, 19 Nov 2018 13:34:21 -0800 Subject: 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`. --- system/fcron/APKBUILD | 4 +- system/fcron/fcron.initd | 103 ++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 96 insertions(+), 11 deletions(-) diff --git a/system/fcron/APKBUILD b/system/fcron/APKBUILD index 718ed33f8..79f12c416 100644 --- a/system/fcron/APKBUILD +++ b/system/fcron/APKBUILD @@ -2,7 +2,7 @@ # Maintainer: A. Wilcox pkgname=fcron pkgver=3.2.1 -pkgrel=0 +pkgrel=1 pkgdesc="periodical command scheduler for systems not always up" url="http://fcron.free.fr/" pkgusers="fcron" @@ -48,4 +48,4 @@ package() { sha512sums="ddfd3e3a297b843c924aacccffaa5c1c6b300497f39daa1cdb90dc4cf4bc757042b0b2c1f055c119c8128c64d830ee0e8757091610432f5ffcacca25d369e5cd fcron-3.2.1.src.tar.gz 7516c9a51b1f6c29f1256c4697028b47f7883bf5fb08ccc585cf49e4edc7598a9730a225a03aaf3749698a94b9d01dda76cd3f352c0c868960fd09374df44199 systab.orig -c5ea27dc7197c1a8d2e00372e3a6f38777c825c7913c320bc6fcc6d8d0e5cc7a11c7f5977d1ed1f05f4b7b55f2f8906fd960900107de6bec757b8b4045b1adaa fcron.initd" +8674743ca9080e3cc1e4ebc610dfe362f9d6bd5525447f1f1aa2066a6746d3323ce23ba1fae2e49b222ed0418f9492bbb3a3c73c8239631c5d6ead4b9259630f fcron.initd" 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 -# 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}" } -- cgit v1.2.3-70-g09d2