###
### Copyright 2000-2007 University of Illinois Board of Trustees
### All rights reserved.
###
### motd.pm - /etc/motd module for psgconf
###
### Campus Information Technologies and Educational Services
### University of Illinois at Urbana-Champaign
###
package PSGConf::Control::motd;
use strict;
use PSGConf::Action::GenerateFile::Literal;
use PSGConf::Data::String;
use PSGConf::Util;
###############################################################################
### policy methods
###############################################################################
sub _policy_expand_tokens
{
my ($self, $psgconf) = @_;
$psgconf->data_obj('motd')->set (
&PSGConf::Util::_expand_tokens(
$psgconf,
$psgconf->data_obj('motd')->get(),
)
);
}
sub _policy_modify_rc_vars
{
my ($self, $psgconf) = @_;
$psgconf->data_obj('rc_vars')->insert(
{ 'update_motd' => 'NO' }
) if ($psgconf->data_obj('platform')->match('freebsd'));
}
###############################################################################
### decide() method
###############################################################################
sub decide
{
my ($self, $psgconf) = @_;
$psgconf->register_actions(
PSGConf::Action::GenerateFile::Literal->new(
name => '/etc/motd',
content => $psgconf->data_obj('motd')->get(),
comment_str => undef
)
);
}
###############################################################################
### constructor
###############################################################################
sub new
{
my ($class, $psgconf) = @_;
my ($self);
$self = {};
bless($self, $class);
$self->{name} = 'motd';
$psgconf->register_data(
motd => PSGConf::Data::String->new()
);
$psgconf->register_policy($self,
motd_expand_tokens => '_policy_expand_tokens',
motd_modify_rc_vars => '_policy_modify_rc_vars',
);
return $self;
}
###############################################################################
### documentation
###############################################################################
1;
__END__
=head1 NAME
PSGConf::Control::motd - psgconf control class for generating /etc/motd
=head1 SYNOPSIS
In F<psgconf_modules>:
Control PSGConf::Control::motd
=head1 DESCRIPTION
The B<PSGConf::Control::motd> module provides a B<psgconf> control object
for generating /etc/motd. 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<motd>
A B<PSGConf::Data::String> object containing the text to be written to
the F</etc/motd> file.
=back
The constructor also registers the following policy methods:
=over 4
=item I<motd_expand_tokens>
Expands the tokens of the form C<%{data_object_name}> in the I<motd>
Data object.
=item I<motd_modify_rc_vars>
On FreeBSD systems, modifies the I<rc_vars> data object (provided by
B<PSGConf::Control::FreeBSD>) to avoid overwriting F</etc/motd>.
=back
=item decide()
Registers a B<PSGConf::Action::GenerateFile::Literal> object to create
F</etc/motd>.
=back
=head1 SEE ALSO
L<perl>
L<PSGConf>
L<PSGConf::Action::GenerateFile::Literal>
L<PSGConf::Control::FreeBSD>
L<PSGConf::Data::String>
L<PSGConf::Util>
L<psgconf-intro>
=cut
syntax highlighted by Code2HTML, v. 0.9.1