1 #!/usr/lib/plan9/bin/rc
3 # Copyright (C) 2009 Andy Spencer
4 # See ../COPYING for terms
11 PATH=/lib/mkinit/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/lib/plan9/bin
15 echo 'usage: '$0' [options] [command]'
18 echo ' -h,--help Print usage information'
19 echo ' -r,--relaod Prevent spawning listeners when reloading'
20 echo ' -t,--test Fake all commands'
23 echo ' boot Execute boot-up procedures'
24 echo ' halt Execute shutdown procedures'
25 echo ' reload Re-execute init process'
26 echo ' mk <rule> Execute mk rule'
27 echo ' start|stop|restart|zap|status <service>'
28 echo ' Start,stop,restart,zap or query status of service'
29 echo ' eval <cmd> Execute command in mkinit process'
39 # Run mk on the init scripts
43 /usr/lib/plan9/bin/mk \
56 echo mkinit -- booting
61 echo mkinit -- restarting $arg
66 case start stop zap status
68 echo mkinit -- $cmd^ing $arg
75 echo mkinit -- running mk cmd [$arg]
77 echo mkinit -- entering runlevel $arg
82 echo mkinit -- $cmd^ing
91 echo mkinit -- unknown command [$cmd] [$arg]
98 --longoptions help,reload,test \
117 fn sigint { pkill -HUP -P $pid }
129 echo ' reload:' $RELOAD
134 # Create fifos if they don't exist
137 if(test ! -e $INITCTL)
145 # Fork /dev/initctl listener
146 { initctld $INITCTL |
149 } <[0=] >[1=] >[2=] &
151 # Fork console listener
152 # Readline uses stdin,stderr
155 { while(line=`{prompt 'mkinit> '}) {
162 while(line=`{prompt 'mkinit> '})
164 echo Respawning on /dev/console..
166 } } </dev/console >/dev/console >[1=2]
172 { while(line=`{read})