mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-09-28 21:11:41 -09:00
package/busybox: add crond init script
The init script will be installed only if no other package provides cron (currently that could be package/dcron). Our current default location for crontabs was the Busybox default of /var/spool/cron/, but /var/spool is stored on tmpfs. This isn't convenient as crontabs should normally be persistent, so we change this default to /etc/cron, which is much more sensible. We also create it to make sure to create this directory. Signed-off-by: Fiona Klute <fiona.klute+wiwa@gmx.de> [Thomas: - Change default location of crontab - Rework init script according to the latest coding style rules] Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
committed by
Thomas Petazzoni
parent
f041540ef5
commit
b341023981
60
package/busybox/S50crond
Normal file
60
package/busybox/S50crond
Normal file
@@ -0,0 +1,60 @@
|
||||
#!/bin/sh
|
||||
|
||||
DAEMON="crond"
|
||||
PIDFILE="/var/run/$DAEMON.pid"
|
||||
|
||||
CROND_ARGS=""
|
||||
|
||||
# shellcheck source=/dev/null
|
||||
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
|
||||
|
||||
# BusyBox' crond does not create a pidfile, so pass "-f" on the crond
|
||||
# command line and use "--make-pidfile" to instruct start-stop-daemon
|
||||
# to create one.
|
||||
start() {
|
||||
printf 'Starting %s: ' "$DAEMON"
|
||||
# shellcheck disable=SC2086 # we need the word splitting
|
||||
start-stop-daemon --start --background --make-pidfile \
|
||||
--pidfile "$PIDFILE" --exec "/usr/sbin/$DAEMON" \
|
||||
-- -f $CROND_ARGS
|
||||
status=$?
|
||||
if [ "$status" -eq 0 ]; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "FAIL"
|
||||
fi
|
||||
return "$status"
|
||||
}
|
||||
|
||||
stop() {
|
||||
printf 'Stopping %s: ' "$DAEMON"
|
||||
start-stop-daemon --stop --pidfile "$PIDFILE" --exec "/usr/sbin/$DAEMON"
|
||||
status=$?
|
||||
if [ "$status" -eq 0 ]; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "FAIL"
|
||||
fi
|
||||
while start-stop-daemon --stop --test --quiet --pidfile "$PIDFILE" \
|
||||
--exec "/sbin/$DAEMON"; do
|
||||
sleep 0.1
|
||||
done
|
||||
rm -f "$PIDFILE"
|
||||
return "$status"
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start|stop|restart)
|
||||
"$1";;
|
||||
reload)
|
||||
# Restart, since there is no true "reload" feature.
|
||||
restart;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|reload}"
|
||||
exit 1
|
||||
esac
|
||||
@@ -782,7 +782,7 @@ CONFIG_CROND=y
|
||||
# CONFIG_FEATURE_CROND_D is not set
|
||||
# CONFIG_FEATURE_CROND_CALL_SENDMAIL is not set
|
||||
CONFIG_FEATURE_CROND_SPECIAL_TIMES=y
|
||||
CONFIG_FEATURE_CROND_DIR="/var/spool/cron"
|
||||
CONFIG_FEATURE_CROND_DIR="/etc/cron"
|
||||
CONFIG_CRONTAB=y
|
||||
# CONFIG_DEVFSD is not set
|
||||
# CONFIG_DEVFSD_MODLOAD is not set
|
||||
|
||||
@@ -312,6 +312,18 @@ define BUSYBOX_INSTALL_SYSCTL_SCRIPT
|
||||
endef
|
||||
endif
|
||||
|
||||
# Only install our crond script if no other package does it.
|
||||
ifeq ($(BR2_PACKAGE_DCRON),)
|
||||
define BUSYBOX_INSTALL_CROND_SCRIPT
|
||||
if grep -q CONFIG_CROND=y $(@D)/.config; \
|
||||
then \
|
||||
mkdir -p $(TARGET_DIR)/etc/cron/crontabs ; \
|
||||
$(INSTALL) -m 0755 -D package/busybox/S50crond \
|
||||
$(TARGET_DIR)/etc/init.d/S50crond; \
|
||||
fi;
|
||||
endef
|
||||
endif
|
||||
|
||||
ifeq ($(BR2_INIT_BUSYBOX),y)
|
||||
define BUSYBOX_INSTALL_INITTAB
|
||||
if test ! -e $(TARGET_DIR)/etc/inittab; then \
|
||||
@@ -407,6 +419,7 @@ define BUSYBOX_INSTALL_INIT_OPENRC
|
||||
$(BUSYBOX_INSTALL_MDEV_SCRIPT)
|
||||
$(BUSYBOX_INSTALL_LOGGING_SCRIPT)
|
||||
$(BUSYBOX_INSTALL_WATCHDOG_SCRIPT)
|
||||
$(BUSYBOX_INSTALL_CROND_SCRIPT)
|
||||
$(BUSYBOX_INSTALL_TELNET_SCRIPT)
|
||||
endef
|
||||
|
||||
@@ -419,6 +432,7 @@ define BUSYBOX_INSTALL_INIT_SYSV
|
||||
$(BUSYBOX_INSTALL_LOGGING_SCRIPT)
|
||||
$(BUSYBOX_INSTALL_WATCHDOG_SCRIPT)
|
||||
$(BUSYBOX_INSTALL_SYSCTL_SCRIPT)
|
||||
$(BUSYBOX_INSTALL_CROND_SCRIPT)
|
||||
$(BUSYBOX_INSTALL_TELNET_SCRIPT)
|
||||
endef
|
||||
|
||||
|
||||
Reference in New Issue
Block a user