#!/usr/bin/perl
#use Mooix::Thing;
use Mooix::CallStack;
#use Mooix::Root;
run sub ($) {
	my $this=shift;

	# Check to see that we were run by init, and there is nothing else
	# on the stack.
        my $init=$Mooix::Root->system->init;
        my $stack=Mooix::CallStack::get();
        # Advance on to the next stack frame -- since this method is
        # stackless, that is its caller.
        my $stack=$stack->nextsegment;
        if (! $stack || $stack->nextsegment ||
            $stack->basemethod ne 'shutdown' || $stack->index ne $init->index) {
                $this->croak("Permission denied; may only be run by init");
        }
	
	$this->allowlogin(0);
	$this->reap(seconds => 0,
		message => "The moo is going down! Please come back later.");

	return 1;
}
