aboutsummaryrefslogtreecommitdiff
path: root/gnu/services/mcron.scm
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/services/mcron.scm')
-rw-r--r--gnu/services/mcron.scm54
1 files changed, 53 insertions, 1 deletions
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