###
###  Copyright 2000-2007 University of Illinois Board of Trustees
###
###  ShellStartupFiles.pm - shell startup files module for psgconf
###
###  Campus Information Technologies and Educational Services
###  University of Illinois at Urbana-Champaign
###


package PSGConf::Control::ShellStartupFiles;

use strict;

use PSGConf::Action::GenerateFile::etc_cshrc;
use PSGConf::Action::GenerateFile::etc_profile;
use PSGConf::Data::Hash;
use PSGConf::Data::List;
use PSGConf::Data::String;


###############################################################################
###  decide() method
###############################################################################

sub decide
{
	my ($self, $psgconf) = @_;
	my ($cshrc, $profile, $path, $manpath, $env_vars, $shell_aliases);

	$cshrc = $psgconf->data_obj('cshrc_path')->get();
	$profile = $psgconf->data_obj('profile_path')->get();
	$path = $psgconf->data_obj('path')->get();
	$manpath = $psgconf->data_obj('manpath')->get();
	$env_vars = $psgconf->data_obj('env_vars')->get();
	$shell_aliases = $psgconf->data_obj('shell_aliases')->get();

	$psgconf->register_actions(
		PSGConf::Action::GenerateFile::etc_cshrc->new(
			name		=> $cshrc,
			description	=> 'csh and tcsh startup file',
			path		=> $path,
			manpath		=> $manpath,
			env_vars	=> $env_vars,
			shell_aliases	=> $shell_aliases,
			commands	=> $psgconf->data_obj('cshrc_commands')->get()
		),
		PSGConf::Action::GenerateFile::etc_profile->new(
			name		=> $profile,
			description	=> 'sh and ksh startup file',
			path		=> $path,
			manpath		=> $manpath,
			env_vars	=> $env_vars,
			shell_aliases	=> $shell_aliases,
			commands	=> $psgconf->data_obj('profile_commands')->get()
		)
	);
}


###############################################################################
###  constructor
###############################################################################

sub new
{
	my ($class, $psgconf) = @_;
	my ($self);

	$self = {};
	bless($self, $class);

	$self->{name} = 'ShellStartupFiles';

	$psgconf->register_data(
		cshrc_path	=> PSGConf::Data::String->new(
					'value_abspath' => 1,
					value => '/etc/csh.cshrc'
				),
		profile_path	=> PSGConf::Data::String->new(
					'value_abspath' => 1,
					value => '/etc/profile'
				),
		cshrc_commands	=> PSGConf::Data::String->new(),
		profile_commands => PSGConf::Data::String->new(),
		path		=> PSGConf::Data::List->new(
					'value_abspath' => 1,
				),
		manpath		=> PSGConf::Data::List->new(
					value_abspath => 1
				),
		env_vars	=> PSGConf::Data::Hash->new(),
		shell_aliases	=> PSGConf::Data::Hash->new()
	);

	return $self;
}


###############################################################################
###  documentation
###############################################################################

1;

__END__

=head1 NAME

PSGConf::Control::ShellStartupFiles - psgconf control class for shell startup files

=head1 SYNOPSIS

In F<psgconf_modules>:

  Control PSGConf::Control::ShellStartupFiles

=head1 DESCRIPTION

The B<PSGConf::Control::ShellStartupFiles> module provides a B<psgconf>
control object for configuring shell startup files.
It supports the following methods:

=over 4

=item new()

The constructor.  Its parameter is a reference to the B<PSGConf>
object.  It registers the following data objects:

=over 4

=item I<cshrc_path>

A B<PSGConf::Data::String> object containing the absolute path to the
system-wide csh(1)/tcsh(1) startup file.  The default is C</etc/csh.cshrc>.

=item I<profile_path>

A B<PSGConf::Data::String> object containing the absolute path to the
system-wide sh(1)/ksh(1) startup file.  The default is C</etc/profile>.

=item I<cshrc_commands>

A B<PSGConf::Data::String> object containing commands to be added to the
csh(1)/tcsh(1) startup file.

=item I<profile_commands>

A B<PSGConf::Data::String> object containing commands to be added to the
sh(1)/ksh(1) startup file.

=item I<path>

A B<PSGConf::Data::List> object containing the directories to be added
to the C<PATH> environment variable.

=item I<manpath>

A B<PSGConf::Data::List> object containing the directories to be added
to the C<MANPATH> environment variable.

=item I<env_vars>

A B<PSGConf::Data::Hash> object containing environment variables to be
set in the shell startup files.

=item I<shell_aliases>

A B<PSGConf::Data::Hash> object containing shell aliases (or functions)
to be set in the shell startup files.  The arguments to the alias should
be encoded with the C<E<lt>ARGSE<gt>> token.

=back

=item decide()

Registers a B<PSGConf::Action::GenerateFile::etc_cshrc> object to
generate the default csh(1)/tcsh(1) startup file in the location
specified by the I<cshrc_path> Data object.  Also registers a
B<PSGConf::Action::GenerateFile::etc_profile> object to generate the default
sh(1)/ksh(1) startup file in the location specified by the I<profile_path>
Data object.

=back

=head1 SEE ALSO

L<perl>

L<PSGConf>

L<PSGConf::Action::GenerateFile::etc_cshrc>

L<PSGConf::Action::GenerateFile::etc_profile>

L<PSGConf::Data::Hash>

L<PSGConf::Data::List>

L<PSGConf::Data::String>

L<psgconf-intro>

=cut



syntax highlighted by Code2HTML, v. 0.9.1