3 # Copyright (C) 2009 Andy Spencer
4 # See ../COPYING for terms
8 usage: $0 [options] [command]
11 -h,--help Print usage information
12 -t,--test Fake all commands
15 boot Execute boot-up procedures
16 halt Execute shutdown procedures
17 reload Re-execute init process
18 mk <rule> Execute mk rule
19 start|stop|restart|zap|status <service>
20 Start,stop,restart,zap or query status of service
21 eval <cmd> Execute command in mkinit process
27 [ "$TEST" ] && export P=true
28 /usr/lib/plan9/bin/mk \
34 TEMP=`getopt -n "$0" \
36 --longoptions test,help \
41 [ "$TEST" ] && echo "\$1=$1"
44 -t|--test ) TEST=true; shift ;;
63 echo "mkinit -- booting"
64 if runamk -a "$args" && ! [ "$TEST" ]; then
65 # booted successuflly, redirect input
66 echo "skipping redirect"
68 #[ -p pipe ] || mkfifo $pipe
72 halt|reboot|poweroff )
73 echo "mkinit -- ${cmd}ing"
75 if [ "$args" -o "$cmd" = reboot -o "$cmd" = poweroff ]; then
76 # mk handles syncing and logging message
77 ${TEST:+echo} $cmd -ndf $args
82 echo "mkinit -- restarting $args"
87 start|stop|zap|status )
89 echo "mkinit -- ${cmd}ing $args"
95 echo "mkinit -- running mk cmd [$args]"
100 exec /sbin/mkinit ${TEST:+"-t"}
106 echo "unknown command [$cmd $args]"
109 read -e -p "mkinit> " cmd args
110 history -s $cmd $args