AboutSummaryRefsLogTreeCommitDiffStats
path: root/src/mcron/scripts/cron.scm
diff options
context:
space:
mode:
authorDale Mellor <mcron-lsfnyl@rdmp.org>2020-05-08 20:43:50 +0100
committerDale Mellor <mcron-lsfnyl@rdmp.org>2020-06-08 08:48:57 +0100
commit6a9bfcea4080390186be859c721e35f438d1272d (patch)
treeea6c01e4336a3209157df9ca05f175f98fe7cb8d /src/mcron/scripts/cron.scm
parentf700f299d41c8f0ecb953f1e02b8fbd432efef3d (diff)
downloadmcron-6a9bfcea4080390186be859c721e35f438d1272d.tar.gz
mcron-6a9bfcea4080390186be859c721e35f438d1272d.tar.bz2
mcron-6a9bfcea4080390186be859c721e35f438d1272d.zip
Using new Guile command-line-processor.
Diffstat (limited to 'src/mcron/scripts/cron.scm')
-rw-r--r--src/mcron/scripts/cron.scm51
1 files changed, 8 insertions, 43 deletions
diff --git a/src/mcron/scripts/cron.scm b/src/mcron/scripts/cron.scm
index 25c8a1a..b8463f6 100644
--- a/src/mcron/scripts/cron.scm
+++ b/src/mcron/scripts/cron.scm
@@ -19,7 +19,6 @@
(define-module (mcron scripts cron)
- #:use-module (ice-9 getopt-long)
#:use-module (ice-9 ftw)
#:use-module (mcron base)
#:use-module (mcron config)
@@ -31,29 +30,6 @@
-(define (show-help)
- (display "Usage: cron [OPTIONS]
-Unless an option is specified, run a cron daemon as a detached process,
-reading all the information in the users' crontabs and in /etc/crontab.
-
- -v, --version Display version
- -h, --help Display this help message
- -sN, --schedule[=]N Display the next N jobs that will be run by cron
- -n, --noetc Do not check /etc/crontab for updates (HIGHLY
- RECOMMENDED).")
- (newline)
- (show-package-information))
-
-
-
-(define %options `((schedule (single-char #\s) (value #t)
- (predicate ,string->number))
- (noetc (single-char #\n) (value #f))
- (version (single-char #\v) (value #f))
- (help (single-char #\h) (value #f))))
-
-
-
(define (delete-run-file)
"Remove the /var/run/cron.pid file so that crontab and other invocations of
cron don't get the wrong idea that a daemon is currently running. This
@@ -107,10 +83,7 @@ operation. The permissions on the /var/cron/tabs directory enforce this."
(mcron-error 4
"You do not have permission to access the system crontabs."))))
-(define (%process-files schedule? noetc?)
- ;; XXX: What is this supposed to do?
- (when schedule?
- (with-output-to-file config-pid-file noop))
+(define (%process-files noetc?)
;; Clear MAILTO so that outputs are sent to the various users.
(setenv "MAILTO" #f)
;; Having defined all the necessary procedures for scanning various sets of
@@ -141,17 +114,10 @@ option.\n")
;;; Entry point.
;;;
-(define* (main #:optional (args (command-line)))
- (let ((opts (getopt-long args %options)))
- (when config-debug
- (debug-enable 'backtrace))
- (cond ((option-ref opts 'help #f)
- (show-help)
- (exit 0))
- ((option-ref opts 'version #f)
- (show-version "cron")
- (exit 0))
- ((not (zero? (getuid)))
+(define (main --schedule --noetc)
+ (when config-debug (debug-enable 'backtrace))
+
+ (cond ((not (zero? (getuid)))
(mcron-error 16
"This program must be run by the root user (and should"
" have been installed as such)."))
@@ -161,12 +127,11 @@ option.\n")
" this is not true, remove the file\n "
config-pid-file ".)"))
(else
- (%process-files (option-ref opts 'schedule #f)
- (option-ref opts 'noetc #f))
- (cond ((option-ref opts 'schedule #f)
+ (cond (--schedule
=> (λ (count)
(display-schedule (max 1 (string->number count)))
- (exit 0)))))))
+ (exit 0))))
+ (%process-files --noetc)))
;; Daemonize ourself.
(unless (eq? 0 (primitive-fork)) (exit 0))