The beginnings of a cron for raptor
parent
f1f628dc0a
commit
f24abc72d1
|
@ -3,6 +3,8 @@ USING: namespaces unix.linux.if unix.linux.ifreq unix.linux.route ;
|
|||
|
||||
IN: raptor
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
! Networking
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
: configure-lo ( -- )
|
||||
|
@ -42,6 +44,8 @@ IN: raptor
|
|||
"mountall.sh" start-service
|
||||
|
||||
start-networking
|
||||
! "loopback" start-service
|
||||
! "networking" start-service
|
||||
|
||||
"hwclock.sh" start-service
|
||||
"displayconfig-hwprobe.py" start-service
|
||||
|
@ -49,7 +53,6 @@ IN: raptor
|
|||
"x11-common" start-service
|
||||
"bootmisc.sh" start-service
|
||||
"urandom" start-service
|
||||
"console-screen.sh" start-service
|
||||
|
||||
! rc2.d
|
||||
|
||||
|
@ -67,24 +70,20 @@ IN: raptor
|
|||
"postfix" start-service
|
||||
"powernowd" start-service
|
||||
"ntp-server" start-service
|
||||
"anacron" start-service
|
||||
"atd" start-service
|
||||
"cron" start-service
|
||||
"binfmt-support" start-service
|
||||
"acpi-support" start-service
|
||||
"rc.local" start-service
|
||||
"rmnologin" start-service
|
||||
|
||||
schedule-cron-jobs
|
||||
start-listeners
|
||||
start-gettys
|
||||
|
||||
] boot-hook set-global
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
[
|
||||
"anacron" stop-service
|
||||
"atd" stop-service
|
||||
"cron" stop-service
|
||||
"acpi-support" stop-service
|
||||
"apmd" stop-service
|
||||
"dbus" stop-service
|
||||
|
@ -112,9 +111,6 @@ IN: raptor
|
|||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
[
|
||||
"anacron" stop-service
|
||||
"atd" stop-service
|
||||
"cron" stop-service
|
||||
"acpi-support" stop-service
|
||||
"apmd" stop-service
|
||||
"dbus" stop-service
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
USING: kernel threads sequences calendar combinators.cleave combinators.lib ;
|
||||
|
||||
IN: raptor.cron
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
TUPLE: when minute hour day-of-month month day-of-week ;
|
||||
|
||||
C: <when> when
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
: slot-match? ( now-slot when-slot -- ? ) dup f = [ 2drop t ] [ member? ] if ;
|
||||
|
||||
: minute-match? ( now when -- ? )
|
||||
[ timestamp-minute ] [ when-minute ] bi* slot-match? ;
|
||||
|
||||
: hour-match? ( now when -- ? )
|
||||
[ timestamp-hour ] [ when-hour ] bi* slot-match? ;
|
||||
|
||||
: day-of-month-match? ( now when -- ? )
|
||||
[ timestamp-day ] [ when-day-of-month ] bi* slot-match? ;
|
||||
|
||||
: month-match? ( now when -- ? )
|
||||
[ timestamp-month ] [ when-month ] bi* slot-match? ;
|
||||
|
||||
: day-of-week-match? ( now when -- ? )
|
||||
[ day-of-week ] [ when-day-of-week ] bi* slot-match? ;
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
: when=now? ( when -- ? )
|
||||
now swap
|
||||
{ [ minute-match? ]
|
||||
[ hour-match? ]
|
||||
[ day-of-month-match? ]
|
||||
[ month-match? ]
|
||||
[ day-of-week-match? ] }
|
||||
<--&& ;
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
: recurring-job ( when quot -- )
|
||||
[ swap when=now? [ call ] [ drop ] if 60000 sleep ] [ recurring-job ] 2bi ;
|
||||
|
||||
: schedule ( when quot -- ) [ recurring-job ] curry curry in-thread ;
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
|
||||
USING: kernel threads arrays sequences combinators.cleave raptor raptor.cron ;
|
||||
|
||||
IN: raptor
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
: fork-exec-args-wait ( args -- ) [ first ] [ ] bi fork-exec-wait ;
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
: cron-hourly ( -- ) ;
|
||||
|
||||
: cron-daily ( -- )
|
||||
{ "/etc/cron.daily/apt"
|
||||
"/etc/cron.daily/aptitude"
|
||||
"/etc/cron.daily/bsdmainutils"
|
||||
"/etc/cron.daily/find.notslocate"
|
||||
"/etc/cron.daily/logrotate"
|
||||
"/etc/cron.daily/man-db"
|
||||
"/etc/cron.daily/ntp-server"
|
||||
"/etc/cron.daily/slocate"
|
||||
"/etc/cron.daily/standard"
|
||||
"/etc/cron.daily/sysklogd"
|
||||
"/etc/cron.daily/tetex-bin" }
|
||||
[ 1array [ fork-exec-args-wait ] in-thread drop ] each ;
|
||||
|
||||
: cron-weekly ( -- )
|
||||
{ "/etc/cron.weekly/cvs"
|
||||
"/etc/cron.weekly/man-db"
|
||||
"/etc/cron.weekly/ntp-server"
|
||||
"/etc/cron.weekly/popularity-contest"
|
||||
"/etc/cron.weekly/sysklogd" }
|
||||
[ 1array [ fork-exec-args-wait ] in-thread drop ] each ;
|
||||
|
||||
: cron-monthly ( -- )
|
||||
{ "/etc/cron.monthly/scrollkeeper"
|
||||
"/etc/cron.monthly/standard" }
|
||||
[ 1array [ fork-exec-args-wait ] in-thread drop ] each ;
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
: schedule-cron-jobs ( -- )
|
||||
{ 17 } f f f f <when> [ cron-hourly ] schedule
|
||||
{ 25 } { 6 } f f f <when> [ cron-daily ] schedule
|
||||
{ 47 } { 6 } f f { 7 } <when> [ cron-weekly ] schedule
|
||||
{ 52 } { 6 } { 1 } f f <when> [ cron-monthly ] schedule ;
|
|
@ -10,7 +10,9 @@ SYMBOL: reboot-hook
|
|||
SYMBOL: shutdown-hook
|
||||
SYMBOL: networking-hook
|
||||
|
||||
: reload-raptor-config ( -- ) "/etc/raptor/config.factor" run-file ;
|
||||
: reload-raptor-config ( -- )
|
||||
"/etc/raptor/config.factor" run-file
|
||||
"/etc/raptor/cronjobs.factor" run-file ;
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
|
|
Loading…
Reference in New Issue