Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Xavier Bachelot
lemonldap-ng
Commits
0e65a2bf
Commit
0e65a2bf
authored
Dec 16, 2009
by
Yadd
Browse files
New utility to migrate from <0.9.5 to >=0.9.5
parent
578d0a0d
Changes
1
Hide whitespace changes
Inline
Side-by-side
modules/lemonldap-ng-common/scripts/lmMigrateConfFiles2ini
0 → 100755
View file @
0e65a2bf
#!/usr/bin/perl
use
strict
;
use
Getopt::
Long
;
use
Config::
IniFiles
;
our
%opts
;
use
Lemonldap::NG::Common::Conf::
Constants
;
$opts
{
dir
}
||=
'
/etc/lemonldap-ng
';
my
$old
=
{
storage
=>
$opts
{
storage
}
||
"
$opts
{dir}/storage.conf
",
apply
=>
$opts
{
apply
}
||
"
$opts
{dir}/apply.conf
",
};
my
$new
=
$opts
{
ini
}
||
"
$opts
{dir}/lemonldap-ng.ini
";
my
$datas
;
-
r
$old
->
{
storage
}
or
quit
(
2
,"
$old
->{storage} is not readeable
");
open
F
,
$old
->
{
storage
};
while
(
<
F
>
){
next
if
(
/^\s*(?:#.*)?$/
);
my
(
$k
,
$v
)
=
(
/^(\w+)\s*=\s*(.*)$/
)
or
quit
(
3
,"
bad line in
$old
->{storage}:
$_
");
$datas
->
{
configuration
}
->
{
$k
}
=
$v
;
}
close
F
;
if
(
-
e
$old
->
{
apply
}){
open
F
,
$old
->
{
apply
};
while
(
<
F
>
){
next
if
(
/^\s*(?:#.*)?$/
);
my
(
$k
,
$v
)
=
(
/^([\w\.\-]+)\s+(.*)$/
)
or
quit
(
3
,"
bad line in
$old
->{apply}:
$_
");
$datas
->
{
apply
}
->
{
$k
}
=
$v
;
}
close
F
;
}
if
(
-
e
$new
){
-
w
$new
or
quit
(
4
,"
$new
is not writeable
");
my
$conf
=
Config::
IniFiles
->
new
(
-
file
=>
$new
);
}
sub
quit
{
print
STDERR
"
$_
[1]
\n
";
exit
$_
[
0
];
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment