factor/extra/raptor/raptor.factor

81 lines
2.3 KiB
Factor
Raw Normal View History

2007-11-15 18:50:03 -05:00
2008-06-30 11:30:52 -04:00
USING: kernel parser namespaces threads arrays sequences unix unix.process
bake ;
2007-11-15 18:50:03 -05:00
IN: raptor
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SYMBOL: boot-hook
SYMBOL: reboot-hook
SYMBOL: shutdown-hook
SYMBOL: networking-hook
2007-11-20 02:59:37 -05:00
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2007-11-15 21:47:51 -05:00
: reload-raptor-config ( -- )
"/etc/raptor/config.factor" run-file
"/etc/raptor/cronjobs.factor" run-file ;
2007-11-15 18:50:03 -05:00
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2007-11-20 02:59:37 -05:00
: fork-exec-wait ( pathname args -- )
fork dup 0 = [ drop exec drop ] [ 2nip wait-for-pid drop ] if ;
2007-11-15 18:50:03 -05:00
2007-11-25 14:37:27 -05:00
: fork-exec-args-wait ( args -- ) [ first ] [ ] bi fork-exec-wait ;
2007-12-05 20:35:19 -05:00
: fork-exec-arg ( arg -- ) 1array [ fork-exec-args-wait ] curry in-thread ;
2007-11-15 18:50:03 -05:00
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2007-11-20 02:59:37 -05:00
: forever ( quot -- ) [ call ] [ forever ] bi ;
2007-11-15 18:50:03 -05:00
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2007-11-20 02:59:37 -05:00
: start-service ( name -- ) "/etc/init.d/" swap " start" 3append system drop ;
: stop-service ( name -- ) "/etc/init.d/" swap " stop" 3append system drop ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2007-11-15 18:50:03 -05:00
: getty ( tty -- ) `{ "/sbin/getty" "38400" , } fork-exec-args-wait ;
2007-11-15 18:50:03 -05:00
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
USING: io io.files io.streams.lines io.streams.plain io.streams.duplex
listener io.encodings.utf8 ;
2007-11-15 18:50:03 -05:00
: tty-listener ( tty -- )
dup utf8 <file-reader> [
swap utf8 <file-writer> [
<duplex-stream> [
listener
] with-stream
] with-disposal
] with-disposal ;
2007-11-15 18:50:03 -05:00
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
USING: unix.linux.swap unix.linux.fs ;
SYMBOL: root-device
SYMBOL: swap-devices
: activate-swap ( -- ) swap-devices get [ 0 swapon drop ] each ;
: mount-root ( -- ) root-device get "/" "ext3" MS_REMOUNT f mount drop ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2007-11-15 18:50:03 -05:00
: start-networking ( -- ) networking-hook get call ;
2007-11-25 14:37:27 -05:00
: set-hostname ( name -- ) `{ "/bin/hostname" , } fork-exec-args-wait ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2007-11-15 18:50:03 -05:00
: boot ( -- ) boot-hook get call ;
: reboot ( -- ) reboot-hook get call ;
: shutdown ( -- ) shutdown-hook get call ;
MAIN: boot
2007-11-20 02:59:37 -05:00