From 002c21f6c89ee3492683ae76a643faa07f1719d0 Mon Sep 17 00:00:00 2001 From: "W. Kosior" Date: Mon, 27 May 2024 00:52:23 +0200 Subject: gnu: mcron: Add traditional cron service. TODO: write good changelog entry Change-Id: Ib1e8f1afcbaae302eac51883e3b02a1d2c32a89e --- gnu/services/mcron.scm | 54 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'gnu') diff --git a/gnu/services/mcron.scm b/gnu/services/mcron.scm index 0e0d07d252..a2bc1a5553 100644 --- a/gnu/services/mcron.scm +++ b/gnu/services/mcron.scm @@ -20,8 +20,12 @@ (define-module (gnu services mcron) #:use-module (gnu services) + #:use-module ((gnu services configuration) #:select + (define-configuration/no-serialization)) #:use-module (gnu services shepherd) + #:use-module (gnu system setuid) #:use-module (gnu packages guile-xyz) + #:use-module ((guix packages) #:select (package?)) #:use-module (guix records) #:use-module (guix gexp) #:use-module (srfi srfi-1) @@ -37,7 +41,12 @@ mcron-configuration-date-format mcron-configuration-home-service? - mcron-service-type)) + mcron-service-type + + cron-daemon-configuration + cron-daemon-configuration-cron + cron-daemon-configuration- + cron-daemon-service-type)) ;;; Commentary: ;;; @@ -214,4 +223,47 @@ files." jobs))))) (default-value (mcron-configuration)))) ;empty job list + + +(define-configuration/no-serialization cron-daemon-configuration + (cron + (package mcron) + "The cron package to use.") + (monitor-etc? + (boolean #f) + "Whether to check /etc/crontab for updates.")) + +(define (cron-daemon-shepherd-services config) + (list (shepherd-service + (provision '(cron-daemon)) + (start #~(make-forkexec-constructor + '(#$(file-append (cron-daemon-configuration-cron config) + "/sbin/cron") + #$@(if (cron-daemon-configuration-monitor-etc? config) + '() + '("--noetc"))) + #:pid-file "/var/run/cron.pid")) + (stop #~(make-kill-destructor))))) + +(define cron-daemon-activation + (const #~(mkdir-p "/var/cron/tabs"))) + +(define (cron-daemon-setuid-programs config) + (list (file-like->setuid-program + (file-append (cron-daemon-configuration-cron config) + "/sbin/crontab-access")))) + +(define cron-daemon-service-type + (service-type (name 'cron-daemon) + (description + "Run the traditional cron daemon.") + (extensions + (list (service-extension shepherd-root-service-type + cron-daemon-shepherd-services) + (service-extension activation-service-type + cron-daemon-activation) + (service-extension setuid-program-service-type + cron-daemon-setuid-programs))) + (default-value (cron-daemon-configuration)))) + ;;; mcron.scm ends here -- cgit v1.2.3