App-LXC-Container

 view release on metacpan or  search on metacpan

lib/App/LXC/Container.pm  view on Meta::CPAN

	require App::LXC::Container::Run;
	App::LXC::Container::Run->import;
    }
}
use App::LXC::Container::Texts;

#########################################################################
#########################################################################

=head1 MAIN FUNCTIONS

The module defines the following main functions for the scripts
C<lxc-app-setup> and C<lxc-app-update>:

=cut

#########################################################################

=head2 B<setup> - setup meta-configuration

    App::LXC::Container::setup($container);

=head3 parameters:

    $container          name of the container to be configured

=head3 description:

This is the actual code for the wrapper script C<lxc-app-setup>.

=cut

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

sub setup($)
{
    defined $ENV{ALC_DEBUG}  and  $ENV{ALC_DEBUG} =~ m/^[0-9]+$/  and
	debug($ENV{ALC_DEBUG});
    my $container = App::LXC::Container::Setup->new(shift);
    $container->main();
}

#########################################################################

=head2 B<update> - update LXC configuration

    App::LXC::Container::update(@containers);

=head3 parameters:

    @container          name of the container(s) to be updated

=head3 description:

This is the actual code for the wrapper script C<lxc-app-update>.

=cut

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

sub update(@)
{
    defined $ENV{ALC_DEBUG}  and  $ENV{ALC_DEBUG} =~ m/^[0-9]+$/  and
	debug($ENV{ALC_DEBUG});
    my $container = App::LXC::Container::Update->new(@_);
    $container->main();
}

#########################################################################

=head2 B<run> - run LXC configuration

    App::LXC::Container::run([@options,] $name, <program> [, <program-options>]);

=head3 parameters:

    @options            parameters for container:
                        {-d|--dir|--directory} <starting-directory>
                        {-u|--user} <user-to-be-used>
    $container          the name of the container to be run

=head3 description:

This is the actual code for the wrapper script C<lxc-app-run>.

=cut

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

sub run(@)
{
    my ($user, $dir) = ('root', '/');
    while (2 < @_  and  $_[0] =~ m/^(?:-[du]|--(?:dir|directory|user))$/)
    {
	if ($_[0] =~ m/^(-u|--user)$/)
	{   shift;   $user = shift;   }
	else
	{   shift;   $dir = shift;   }
    }
    my $name = shift;
    $name =~ m/^[A-Za-z][-A-Z_a-z.0-9]+$/  or  fatal 'bad_container_name';
    defined $ENV{ALC_DEBUG}  and  $ENV{ALC_DEBUG} =~ m/^[0-9]+$/  and
	debug($ENV{ALC_DEBUG});
    my $container = App::LXC::Container::Run->new($name, $user, $dir, @_);
    $container->main();
}

#########################################################################
# Trick to see previously stored standard error output even when Curses
# clears the screen at the very end of program:

END {
    if ($ui  and  UI::Various::using() eq 'Curses')
    {
        print STDERR "\r\n waiting 10 seconds before screen is cleared\r\n";
        sleep 10;
    }
}

1;



( run in 1.156 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )