Lemonldap-NG-Manager
view release on metacpan or search on metacpan
lib/Lemonldap/NG/Manager/Cli.pm view on Meta::CPAN
sub rollback {
my ($self) = @_;
my $lastCfg = $self->mgr->confAcc->lastCfg;
my $previousCfg = $lastCfg - 1;
my $conf =
$self->mgr->confAcc->getConf( { cfgNum => $previousCfg, raw => 1 } )
or die $Lemonldap::NG::Common::Conf::msg;
$conf->{cfgNum} = $lastCfg;
$conf->{cfgAuthor} = scalar( getpwuid $< ) . '(command-line-interface)';
chomp $conf->{cfgAuthor};
$conf->{cfgAuthorIP} = '127.0.0.1';
$conf->{cfgDate} = time;
$conf->{cfgVersion} = $Lemonldap::NG::Manager::VERSION;
$conf->{cfgLog} = $self->log // "Rolled back configuration $lastCfg";
my $s = $self->mgr->confAcc->saveConf($conf);
if ( $s > 0 ) {
$self->logger->info("CLI: Configuration $lastCfg has been rolled back");
print STDERR "Configuration $lastCfg has been rolled back\n";
lib/Lemonldap/NG/Manager/Cli.pm view on Meta::CPAN
print STDERR "$msg\n";
}
}
my $saveParams = { force => $self->force };
if ( $self->force and $self->cfgNum ) {
$self->logger->debug( "CLI: cfgNum forced with " . $self->cfgNum );
print STDERR "cfgNum forced with ", $self->cfgNum;
$saveParams->{cfgNum} = $self->cfgNum;
$saveParams->{cfgNumFixed} = 1;
}
$new->{cfgAuthor} = scalar( getpwuid $< ) . '(command-line-interface)';
chomp $new->{cfgAuthor};
$new->{cfgAuthorIP} = '127.0.0.1';
$new->{cfgDate} = time;
$new->{cfgVersion} = $Lemonldap::NG::Manager::VERSION;
$new->{cfgLog} = $self->log // 'Modified with LL::NG CLI';
$new->{key} ||= join( '',
map { chr( int( ord( Crypt::URandom::urandom(1) ) * 94 / 256 ) + 33 ) }
( 1 .. 16 ) );
my $s = $self->mgr->confAcc->saveConf( $new, %$saveParams );
( run in 0.232 second using v1.01-cache-2.11-cpan-8d75d55dd25 )