###
### Copyright 2000-2007 University of Illinois Board of Trustees
### All rights reserved.
###
### FreeBSD.pm - FreeBSD module for psgconf
###
### Campus Information Technologies and Educational Services
### University of Illinois at Urbana-Champaign
###
package PSGConf::Control::FreeBSD;
use strict;
use PSGConf::Action::GenerateFile::EnvFile;
use PSGConf::Data::Hash;
###############################################################################
### policy methods
###############################################################################
require Exporter;
our @ISA = qw (Exporter);
our %EXPORT_TAGS = ( 'all' => [ qw( _mod_periodic ) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} });
our @EXPORT = qw();
sub _mod_periodic
{
my ($self, $psgconf) = @_;
$psgconf->data_obj('periodic')->insert ({
$self->{periodic} => $self->{periodic_value}
}) if ( ! defined $psgconf->data_obj('periodic')->find($self->{periodic}));
}
sub _policy_modify_periodic
{
my ($self, $psgconf) = @_;
$self->{periodic} = 'daily_status_security_logdir';
$self->{periodic_value} = $psgconf->data_obj('log_dir')->get() . '/syslog';
$self->_mod_periodic($psgconf);
}
###############################################################################
### decide() method
###############################################################################
sub decide
{
my ($self, $psgconf) = @_;
return
if (! $psgconf->data_obj('platform')->match('freebsd'));
$psgconf->register_actions(
PSGConf::Action::GenerateFile::EnvFile->new(
'name' => '/etc/rc.conf',
'description' => 'FreeBSD startup config file',
'quote_values' => 1,
'requires_reboot' => 1,
'vars' => $psgconf->data_obj('rc_vars')->get()
),
PSGConf::Action::GenerateFile::EnvFile->new(
'name' => '/etc/sysctl.conf',
'description' => 'FreeBSD system control file',
'requires_reboot' => 1,
'vars' => $psgconf->data_obj('sysctl_vars')->get()
),
PSGConf::Action::GenerateFile::EnvFile->new(
'name' => '/etc/periodic.conf',
'comment_str' => '###',
'description' => 'FreeBSD periodic config file',
'backup' => 1,
'quote_values' => 1,
'vars' => $psgconf->data_obj('periodic')->get()
)
);
}
###############################################################################
### Constructor
###############################################################################
sub new
{
my ($class, $psgconf) = @_;
my ($self);
$self = {};
bless($self, $class);
$self->{name} = 'FreeBSD';
$psgconf->register_data(
'rc_vars' => PSGConf::Data::Hash->new(),
'sysctl_vars' => PSGConf::Data::Hash->new(),
'periodic' => PSGConf::Data::Hash->new(),
);
$psgconf->register_policy($self,
freebsd_modify_periodic => '_policy_modify_periodic'
);
return $self;
}
###############################################################################
### documentation
###############################################################################
1;
__END__
=head1 NAME
PSGConf::Control::FreeBSD - psgconf control class for FreeBSD-specific configuration
=head1 SYNOPSIS
In F<psgconf_modules>:
Control PSGConf::Control::FreeBSD
=head1 DESCRIPTION
The B<PSGConf::Control::FreeBSD> module provides a B<psgconf> control object
for FreeBSD-specific configuration. 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<rc_vars>
A B<PSGConf::Data::Hash> object that contains definitions for rc
variables to be added to F</etc/rc.conf>.
=item I<sysctl_vars>
A B<PSGConf::Data::Hash> object that contains definitions for system
control variables to be added to F</etc/sysctl.conf>.
=item I<periodic>
A B<PSGConf::Data::Hash> object that contains definitions for control
variables to be added to F</etc/periodic.conf>.
=back
=item decide()
Under systems other than FreeBSD, returns without doing anything.
Otherwise, registers B<PSGConf::Action::GenerateFile::EnvFile> action
objects to create the F</etc/rc.conf>, F</etc/sysctl.conf> and
F</etc/periodic.conf> files.
=back
=head1 SEE ALSO
L<perl>
C<CE<lt>rc.conf(5)E<gt>>
C<CE<lt>periodic.conf(5)E<gt>>
C<CE<lt>sysctl.conf(5)E<gt>>
L<PSGConf>
L<PSGConf::Action::GenerateFile::EnvFile>
L<PSGConf::Data::Hash>
L<psgconf-intro>
=cut
syntax highlighted by Code2HTML, v. 0.9.1