### ### Copyright 2000-2007 University of Illinois Board of Trustees ### All rights reserved. ### ### Inittab.pm - /etc/inittab control module for psgconf ### ### Campus Information Technologies and Educational Services ### University of Illinois at Urbana-Champaign ### package PSGConf::Control::Inittab; use strict; use PSGConf::Data::Boolean; use PSGConf::Data::Table; use PSGConf::Data::List; use PSGConf::Action::GenerateFile::Literal; use PSGConf::Action::RunCommand; ############################################################################### ### Policy methods ############################################################################### sub _policy_check_actions { my ($self, $psgconf) = @_; my ($row); return if ( $psgconf->data_obj('inittab_enable')->equals('false') ); foreach $row ( @{$psgconf->data_obj('inittab')->get()} ) { warn "Invalid Action for inittab entry $row->[0] ($row->[2])\n" if ( length $row->[2] && ! grep /^$row->[2]$/, @{$psgconf->data_obj('inittab_actions')->get()} ); } } ############################################################################### ### decide() method ############################################################################### sub decide { my ($self, $psgconf) = @_; my ($content, $row); return if ( $psgconf->data_obj('inittab_enable')->equals('false') ); ### Some platforms require that initdefault and sysinit be the ### first two entries in the file. foreach $row ( @{$psgconf->data_obj('inittab')->get()} ) { $content .= join (':', @$row) . "\n"; } $psgconf->register_actions ( PSGConf::Action::GenerateFile::Literal->new( name => '/etc/inittab', description => "script for init", comment_str => $psgconf->data_obj('inittab_comment_str')->get(), content => $content ), PSGConf::Action::RunCommand->new( name => 'Reread /etc/inittab', command => $psgconf->data_obj('init_refresh_cmd')->get(), filename => [ '/etc/inittab' ] ) ); } ############################################################################### ### Constructor ############################################################################### sub new { my ($class, $psgconf) = @_; my ($self); $self = {}; bless($self, $class); $self->{name} = 'inittab'; $psgconf->register_data( inittab_enable => PSGConf::Data::Boolean->new( value => 'false' ), inittab_actions => PSGConf::Data::List->new(), inittab_comment_str => PSGConf::Data::String->new( value => "###" ), inittab => PSGConf::Data::Table->new(), init_refresh_cmd => PSGConf::Data::String->new( 'value_abspath' => 1, value => "/sbin/telinit q" ) ); $psgconf->register_policy($self, inittab_check_actions => '_policy_check_actions', ); return $self; } ############################################################################### ### documentation ############################################################################### 1; __END__ =head1 NAME PSGConf::Control::Inittab - psgconf control class for /etc/inittab =head1 SYNOPSIS In F: Control PSGConf::Control::Inittab =head1 DESCRIPTION The B module provides a B control object for configuring the F file. It supports the following methods: =over 4 =item new() The constructor. Its parameter is a reference to the B object. It registers the following data objects: =over 4 =item I A B flag to determine whether or not we should administer the F file. =item I A B of actions that are valid for the F file. =item I A B to use as the comment character in the F file. Defaults to C<###>. Setting it to C will remove any comments in the file. =item I A B of the entries to put into the F file. Order is preserved. =item I A B for a command to run after the F file has been updated. Defaults to C. =back The constructor also registers the following policy methods: =over 4 =item I Compares all actions in the C hash with the actions listed in the list. =back =item decide() Instantiates and registers action objects, as follows: =over 4 =item * Registers B action objects to create the F file from the contents of I. =item * Registers B action objects to run the I. =back =back =head1 SEE ALSO L L L L L L L L =cut