###
### Copyright 2000-2007 University of Illinois Board of Trustees
### All rights reserved.
###
### Solaris.pm - Solaris module for psgconf
###
### Campus Information Technologies and Educational Services
### University of Illinois at Urbana-Champaign
###
package PSGConf::Control::Solaris;
use strict;
use PSGConf::Action::GenerateFile::etc_system;
use PSGConf::Action::GenerateFile::EnvFile;
use PSGConf::Action::MkDir;
use PSGConf::Action::RunCommand;
use PSGConf::Data::Hash;
use PSGConf::Data::String;
###############################################################################
### PSGConf::Action::RunCommand plugin for dumpadm
###############################################################################
sub _check_dumpadm
{
my ($action, $psgconf) = @_;
return (! -d '/var/crash/' . $psgconf->data_obj('hostname')->get());
}
###############################################################################
### decide() method
###############################################################################
sub decide
{
my ($self, $psgconf) = @_;
my ($admin);
return
if (! $psgconf->data_obj('platform')->match('solaris'));
$admin = $psgconf->data_obj('pkg_admin')->get();
$psgconf->register_actions(
PSGConf::Action::GenerateFile::etc_system->new(
'name' => '/etc/system',
'comment_str' => '***',
'description' => 'Solaris kernel config file',
'requires_reboot' => 1,
system_vars => $psgconf->data_obj('system_vars')->get(),
system_literal => $psgconf->data_obj('system_literal')->get()
),
PSGConf::Action::MkDir->new(
'name' => '/var/crash/' . $psgconf->data_obj('hostname')->get(),
'mode' => 0700,
'requires_reboot' => 1
),
PSGConf::Action::RunCommand->new(
'name' => '/etc/dumpadm.conf',
'check_func' => \&_check_dumpadm,
'command' => '/usr/sbin/dumpadm -s /var/crash/'
. $psgconf->data_obj('hostname')->get(),
'requires_reboot' => 1
),
(map {
PSGConf::Action::GenerateFile::EnvFile->new(
'name' => "/var/sadm/install/admin/$_",
'comment_str' => '###',
'description' => 'pkgadd admin file',
'vars' => $admin->{$_}
)} keys %$admin)
);
###
### Run the kbd command only on machines that have /dev/kbd, this
### is not the case for Solaris Zones (non global ones).
###
if ( $psgconf->data_obj('solaris_kbd')->count() && -e '/dev/kbd' ) {
$psgconf->register_actions(
PSGConf::Action::GenerateFile::EnvFile->new(
'name' => "/etc/default/kbd",
'comment_str' => '###',
'description' => 'kbd default settings file',
'vars' => $psgconf->data_obj('solaris_kbd')->get()
),
PSGConf::Action::RunCommand->new(
'name' => 'Update default kbd options',
'command' => '/usr/bin/kbd -i',
'filename' => [ '/etc/default/kbd' ]
)
);
}
}
###############################################################################
### Constructor
###############################################################################
sub new
{
my ($class, $psgconf) = @_;
my ($self);
$self = {};
bless($self, $class);
$self->{name} = 'Solaris';
$psgconf->register_data(
'system_literal' => PSGConf::Data::String->new(),
'system_vars' => PSGConf::Data::Hash->new(),
'solaris_kbd' => PSGConf::Data::Hash->new(),
'pkg_admin' => PSGConf::Data::Hash->new(
value_type => 'HASH'
)
);
return $self;
}
###############################################################################
### documentation
###############################################################################
1;
__END__
=head1 NAME
PSGConf::Control::Solaris - psgconf control class for Solaris-specific configuration
=head1 SYNOPSIS
In F<psgconf_modules>:
Control PSGConf::Control::Solaris
=head1 DESCRIPTION
The B<PSGConf::Control::Solaris> module provides a B<psgconf> control object
for Solaris-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<system_literal>
A B<PSGConf::Data::String> object that contains literal text to be added
to F</etc/system>.
=item I<system_vars>
A B<PSGConf::Data::Hash> object that contains definitions for system
variables to be added to F</etc/system>.
=item I<solaris_kbd>
A B<PSGConf::Data::Hash> object that contains definitions for the
F</etc/default/kbd> file.
=item I<pkg_admin>
A B<PSGConf::Data::Hash> object that contains definitions for a
C<admin(4)> file where the filename is the key, and the contents
is an anomoyous hash of values to put into the admin file.
=back
=item decide()
Under systems other than Solaris, returns without doing anything.
Otherwise, does the following:
=over 4
=item *
Registers a B<PSGConf::Action::GenerateFile::etc_system> action object
to create F</etc/system>.
=item *
Registers a B<PSGConf::Action::MkDir> action object to create the
directory F</var/crash/I<hostname>>. (The I<hostname> data object is
provided by the B<PSGConf::Control::Core> module.)
=item *
Registers a B<PSGConf::Action::RunCommand> action object to run the
C<dumpadm> command to set the dump directory to
F</var/crash/I<hostname>>.
=item *
Registers a B<PSGConf::Action::GenerateFile::EnvFile> for each key in
the I<pkg_admin> hash to create the admin files in F</var/sadm/install/admin>
diretory.
=item *
Registers a B<PSGConf::Action::GenerateFile::EnvFile> for creating the
F</etc/default/kbd> file from the contents of the I<solaris_kbd> hash.
=item *
Registers a B<PSGConf::Action::RunCommand> action object to run the
C<kbd -i> command every time the F</etc/default/kbd> file is updated.
=back
=back
=head1 SEE ALSO
L<perl>
system(4)
dumpadm(1M)
L<PSGConf>
L<PSGConf::Action::GenerateFile::etc_system>
L<PSGConf::Action::GenerateFile::EnvFile>
L<PSGConf::Action::MkDir>
L<PSGConf::Action::RunCommand>
L<PSGConf::Control::Core>
L<PSGConf::Data::Hash>
L<PSGConf::Data::String>
L<psgconf-intro>
=cut
syntax highlighted by Code2HTML, v. 0.9.1