3 # Copyright (C) 2009 Andy Spencer
4 # See ../COPYING for terms
15 PATH=/lib/mkinit/bin:/bin:/sbin:/usr/bin:/usr/sbin
20 echo 'usage: '$0' [options] [command]'
23 echo ' -h,--help Print usage information'
24 echo ' -t,--test Fake all commands'
25 echo ' -d,--daemon For spawning stdin listener'
28 echo ' boot Execute boot-up procedures'
29 echo ' halt Execute shutdown procedures'
30 echo ' reload Re-execute init process'
31 echo ' mk <rule> Execute mk rule'
32 echo ' start|stop|restart|zap|status <service>'
33 echo ' Start,stop,restart,zap or query status of service'
34 echo ' eval <cmd> Execute command in mkinit process'
40 TMP=`getopt -n "$0" -o htd -l help,test,daemon -- "$@"`
46 while [ ! "$1" == "--" ]; do
49 -t|--test ) TESTING=true ;;
50 -d|--daemon ) DAEMON=true ;;
62 echo ' TESTING:' $TESTING 1>&2
63 echo ' DAEMON:' $DAEMON 1>&2
64 echo ' COMMAND:' $COMMAND 1>&2
68 # Run mk on the init scripts
72 export MKINIT_STATE=/tmp/mkinit_state
73 mkdir -p $MKINIT_STATE
75 /usr/lib/plan9/bin/mk \
84 echo mkinit -- running "$cmd" "$@"
96 start|stop|zap|status )
106 poweroff|reboot|kexec|halt)
107 ( runamk "$cmd" "$@" & )
121 # Run whatever was requested
122 process "${COMMAND[@]}"
124 # Fork console listener
126 while read -ep "mkinit> " line; do
131 exec 0</dev/console 1>/dev/console 2>&1
132 echo "Respawning on /dev/console.."