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 \
52 echo mkinit -- booting
57 echo mkinit -- restarting $arg
62 start|stop|zap|status )
64 echo mkinit -- ${cmd}ing $arg
71 echo mkinit -- running mk cmd [$arg]
72 [ "$cmd" = runlevel ] &&
73 echo mkinit -- entering runlevel $arg
78 echo mkinit -- ${cmd}ing
87 echo mkinit -- unknown command [$cmd] [$arg]
93 if [ $$ != 1 -a $1 != "-t" ]; then
101 --longoptions help,reload,test \
106 while [ ! "$1" == "--" ]; do
120 trap "pkill -HUP -P $$" EXIT
132 echo ' reload:' $RELOAD
137 # Create fifos if they don't exist
140 test ! -e $INITCTL &&
148 # Fork /dev/initctl listener
149 ( exec 0<&- 1<&- 2<&-
155 # Fork console listener
156 # Readline uses stdin,stderr
159 while read -e -p "mkinit> " line; do
164 exec 0</dev/console 2>/dev/console
165 echo "Respawning on /dev/console.." >&2
169 # Close stdin, stderr