App-LXC-Container

 view release on metacpan or  search on metacpan

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


The module defines the following main methods which are used by
L<App::LXC::Container>:

=cut

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

=head2 B<new> - create configuration object for application container

    $configuration = App::LXC::Container::Setup->new($container);

=head3 parameters:

    $container          name of the container to be configured

=head3 description:

This is the constructor for the object used to create or update the
configuration of an application container.  If it is used for the very first
time it creates a symbolic link to the configuration directory in the user's
C<HOME> directory.  It also initialises the configuration directory if
necessary.  If a configuration with the given name already exist it is read,
otherwise the object is initialised with the default values needed for a
minimal container.

=head3 returns:

the configuration object for the application container

=cut

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

sub new($$)
{
    my $class = shift;
    $class eq __PACKAGE__  or  fatal 'bad_call_to__1', __PACKAGE__ . '->new';
    local $_ = shift;
    debug(1, __PACKAGE__, '::new("', $_, '")');
    m/^[A-Za-z][-A-Z_a-z.0-9]+$/  or  fatal 'bad_container_name';

    my %configuration = (MAIN_UI => UI::Various::Main->new(),
			 audio => 0,
			 filter => ['EM /var/log'],
			 mounts => [],
			 name => $_,
			 network => 0,
			 ok => 0,
			 packages => [],
			 users => [],
			 x11 => 0);
    my $self = bless \%configuration, $class;
    unless (-e _ROOT_DIR_)
    {	$self->_init_config_dir();   }
    unless (-l _ROOT_DIR_)
    {
	# uncoverable branch false
	if (-e _ROOT_DIR_)
	{
	    fatal '_1_is_not_a_symbolic_link' , _ROOT_DIR_;
	}
	else
	{
	    # This could only happen if symbolic link got deleted after
	    # creation in _init_config_dir:
	    # uncoverable statement
	    fatal 'internal_error__1' ,
		_ROOT_DIR_ . ' does not exist in Setup::new';
	}
    }
    $self->_parse_master();
    $self->_parse_packages();
    $self->_parse_mounts();
    $self->_parse_filter();
    return $self;
}

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

=head2 B<main> - create and run main configuration window

    $configuration->main();

=head3 description:

This method creates and runs the actual application window used to create or
modify the configuration of an application container.

=cut

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

sub main($)
{
    my $self = shift;
    debug(1, __PACKAGE__, '::main($self)');

    $self->_create_main_window();
    $self->{MAIN_UI}->mainloop;
    $self->_save_configuration()  if  $self->{ok};
}

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

=head1 HELPER METHODS / FUNCTIONS

The following methods and functions should not be used outside of this
module itself:

=cut

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

=head2 _add_dialog - run file-selection dialog

    $self->_add_dialog($title, $directory, $code);

=head3 parameters:



( run in 2.960 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )