|
|
|
@ -5,15 +5,21 @@ use Getopt::Long; |
|
|
|
|
use Lemonldap::NG::Common::Conf; |
|
|
|
|
|
|
|
|
|
my %opts; |
|
|
|
|
my $result = |
|
|
|
|
GetOptions( \%opts, 'help|h', 'current|c=s', 'new|n=s', 'latest|l' ); |
|
|
|
|
my $result = GetOptions( \%opts, 'help|h', 'current|c=s', 'new|n=s', 'latest|l', |
|
|
|
|
'force|f' ); |
|
|
|
|
|
|
|
|
|
if ( $opts{help} or not( $opts{current} and $opts{new} ) ) { |
|
|
|
|
print STDERR |
|
|
|
|
"Usage: $0 --current=/current/lemonldap-ng.ini --new=/new/lemonldap-ng.ini\n"; |
|
|
|
|
print STDERR "# other parameters: |
|
|
|
|
print STDERR " |
|
|
|
|
## Lemonldap::NG configuration converter ## |
|
|
|
|
|
|
|
|
|
Usage: $0 --current=/current/lemonldap-ng.ini --new=/new/lemonldap-ng.ini |
|
|
|
|
|
|
|
|
|
other parameters: |
|
|
|
|
--latest -l |
|
|
|
|
convert only last configuration |
|
|
|
|
--force -f |
|
|
|
|
continue even if an error occurs |
|
|
|
|
|
|
|
|
|
"; |
|
|
|
|
exit 1; |
|
|
|
|
} |
|
|
|
@ -30,7 +36,7 @@ foreach ( $opts{current}, $opts{new} ) { |
|
|
|
|
} |
|
|
|
|
my $old = Lemonldap::NG::Common::Conf->new( |
|
|
|
|
{ |
|
|
|
|
confFile => $opts{current}, |
|
|
|
|
confFile => $opts{current}, |
|
|
|
|
noCache => 1, |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
@ -41,7 +47,7 @@ unless ($old) { |
|
|
|
|
} |
|
|
|
|
my $new = Lemonldap::NG::Common::Conf->new( |
|
|
|
|
{ |
|
|
|
|
confFile => $opts{new}, |
|
|
|
|
confFile => $opts{new}, |
|
|
|
|
force => 1, |
|
|
|
|
noCache => 1, |
|
|
|
|
cfgNumFixed => 1, |
|
|
|
@ -63,15 +69,22 @@ foreach (@available) { |
|
|
|
|
my $conf = $old->getConf( { cfgNum => $_ } ); |
|
|
|
|
eval { |
|
|
|
|
delete $conf->{reVHosts}; |
|
|
|
|
delete $conf->{cipher}; |
|
|
|
|
delete $conf->{cipher}; |
|
|
|
|
}; |
|
|
|
|
unless ($conf) { |
|
|
|
|
print STDERR |
|
|
|
|
"\nFailed to get conf $_ : $Lemonldap::NG::Common::Conf::msg\n"; |
|
|
|
|
next if ( $opts{force} ); |
|
|
|
|
exit 6; |
|
|
|
|
} |
|
|
|
|
print "Conf $conf->{cfgNum}:"; |
|
|
|
|
my $r = $new->saveConf($conf); |
|
|
|
|
print( $r ? "stored" : "failed: $Lemonldap::NG::Common::Conf::msg" ); |
|
|
|
|
print "\n"; |
|
|
|
|
if ( my $r = $new->saveConf($conf) ) { |
|
|
|
|
print "Conf $conf->{cfgNum} stored\n"; |
|
|
|
|
next; |
|
|
|
|
} |
|
|
|
|
print STDERR |
|
|
|
|
"Unable to store configuration $conf->{cfgNum}: $Lemonldap::NG::Common::Conf::msg"; |
|
|
|
|
next if ( $opts{force} ); |
|
|
|
|
exit 7; |
|
|
|
|
} |
|
|
|
|
exit 0; |
|
|
|
|
|
|
|
|
|