3 # Copyright (C) 2009 Andy Spencer
4 # See ../COPYING for terms
11 PATH=/lib/mkinit/bin:/bin:/sbin:/usr/bin:/usr/sbin
16 echo 'usage: '$0' [options] [command]'
19 echo ' -h,--help Print usage information'
20 echo ' -r,--relaod Prevent spawning listeners when reloading'
21 echo ' -t,--test Fake all commands'
24 echo ' boot Execute boot-up procedures'
25 echo ' halt Execute shutdown procedures'
26 echo ' reload Re-execute init process'
27 echo ' mk <rule> Execute mk rule'
28 echo ' start|stop|restart|zap|status <service>'
29 echo ' Start,stop,restart,zap or query status of service'
30 echo ' eval <cmd> Execute command in mkinit process'
34 # Run mk on the init scripts
38 /usr/lib/plan9/bin/mk \
51 echo mkinit -- booting
56 echo mkinit -- restarting $arg
61 start|stop|zap|status )
63 echo mkinit -- ${cmd}ing $arg
70 echo mkinit -- running mk cmd [$arg]
71 [ "$cmd" = runlevel ] &&
72 echo mkinit -- entering runlevel $arg
77 echo mkinit -- ${cmd}ing
86 echo mkinit -- unknown command [$cmd] [$arg]
94 --longoptions help,reload,test \
99 while [ ! "$1" == "--" ]; do
113 trap "pkill -HUP -P $$" EXIT
125 echo ' reload:' $RELOAD
130 # Create fifos if they don't exist
133 test ! -e $INITCTL &&
140 if [ ! "$RELOAD" ]; then
141 # Fork /dev/initctl listener
142 ( exec 0<&- 1<&- 2<&-
148 # Fork console listener
149 # Readline uses stdin,stderr
152 while read -e -p "mkinit> " line; do
157 exec 0</dev/console 2>/dev/console
158 echo "Respawning on /dev/console.." >&2
162 # Close stdin, stderr