environments/ppa-mbqj77/deployments/1
parent
2523a54943
commit
8807ddea7e
@ -0,0 +1,109 @@ |
||||
#!/usr/bin/perl |
||||
|
||||
use Getopt::Std; |
||||
use Lemonldap::NG::Manager::Conf; |
||||
use strict; |
||||
|
||||
# Get ARGS |
||||
my %opts; |
||||
getopts( 'cau:p:t:', \%opts ); |
||||
|
||||
|
||||
usage("configuration file required") |
||||
unless ( $ARGV[0] ); |
||||
usage(qq#$ARGV[0] is not readable#) |
||||
unless ( -r $ARGV[0] ); |
||||
|
||||
my $table = $opts{t} || 'lmConfig'; |
||||
if($opts{c}) { |
||||
print "CREATE TABLE $table ( |
||||
cfgNum int not null primary key, |
||||
locationRules text, |
||||
exportedHeaders text, |
||||
globalStorage text, |
||||
globalStorageOptions text, |
||||
macros text, |
||||
groups text, |
||||
portal text, |
||||
domain text, |
||||
ldapServer text, |
||||
ldapPort int, |
||||
ldapBase text, |
||||
securedCookie int, |
||||
cookieName text, |
||||
authentication text, |
||||
exportedVars text, |
||||
managerDn text, |
||||
managerPassword text, |
||||
whatToTrace text\n);\n"; |
||||
} |
||||
|
||||
my $fields; |
||||
open FILE, $ARGV[0]; |
||||
$/ = ""; |
||||
while (<FILE>) { |
||||
my ( $k, $v ) = split /\n\s+/; |
||||
chomp $k; |
||||
next unless($k); |
||||
$v =~ s/\n*$//; |
||||
$fields->{$k} = $v; |
||||
} |
||||
print "INSERT INTO " |
||||
. $table . " (\n\t" |
||||
. join( ",\n\t", keys(%$fields) ) |
||||
. ")\n VALUES (\n\t" |
||||
. join( ",\n\t", values(%$fields) ) |
||||
. "\n );\n"; |
||||
close FILE; |
||||
|
||||
sub usage { |
||||
print STDERR shift; |
||||
print STDERR "\nusage: $0 <options> file |
||||
Options: |
||||
-t table : name of the table (default: lmConfig) |
||||
-c : add 'create table' instruction\n"; |
||||
exit 1; |
||||
} |
||||
1; |
||||
__END__ |
||||
=head1 NAME |
||||
|
||||
lmConfig_File2MySQL - Perl utility to convert Lemonldap::NG configuration file |
||||
into MySQL SQL file. |
||||
|
||||
=head1 SYNOPSIS |
||||
|
||||
lmConf_File2MySQL <options> /path/to/lmConf-1 |
||||
|
||||
=head1 DESCRIPTION |
||||
|
||||
Use this software to convert Lemonldap::NG configuration file into SQL |
||||
instructions. |
||||
|
||||
=head2 Options |
||||
|
||||
=over |
||||
|
||||
=item * -c : add "create table" instruction |
||||
|
||||
=item * -t : name of the table (lmConfig by default) |
||||
|
||||
=back |
||||
|
||||
=head1 SEE ALSO |
||||
|
||||
Lemonldap::NG::Manager |
||||
|
||||
=head1 AUTHOR |
||||
|
||||
Xavier Guimard, E<lt>x.guimard@free.frE<gt> |
||||
|
||||
=head1 COPYRIGHT AND LICENSE |
||||
|
||||
Copyright (C) 2007 by LCL Guimard |
||||
|
||||
This library is free software; you can redistribute it and/or modify |
||||
it under the same terms as Perl itself, either Perl version 5.8.8 or, |
||||
at your option, any later version of Perl 5 you may have available. |
||||
|
||||
=cut |
Loading…
Reference in new issue