|
|
ba46c7 |
From 5b782cffd0c2779dc7d156aec9e9e5f970e6bf40 Mon Sep 17 00:00:00 2001
|
|
|
ba46c7 |
From: Noriko Hosoi <nhosoi@redhat.com>
|
|
|
ba46c7 |
Date: Fri, 4 Oct 2013 11:38:33 -0700
|
|
|
ba46c7 |
Subject: [PATCH 34/39] Ticket #53 - Need to update supported locales
|
|
|
ba46c7 |
commit e0c78d5b87d4d798a936eba9c90f5db5347bcb3c did not include
|
|
|
ba46c7 |
the upgreade script: 60upgradeconfigfiles.pl.
|
|
|
ba46c7 |
Note: This is a part of 389-ds-base-1.3.2.0.
|
|
|
ba46c7 |
(cherry picked from commit 64e0b3799971fa17aae7260ae238e9f68f66c3bd)
|
|
|
ba46c7 |
(cherry picked from commit 5950daa74ef929d6543b04baf2255c65e606a97d)
|
|
|
ba46c7 |
|
|
|
ba46c7 |
---
|
|
|
ba46c7 |
ldap/admin/src/scripts/60upgradeconfigfiles.pl | 69 ++++++++++++++++++++++++
|
|
|
ba46c7 |
1 files changed, 69 insertions(+), 0 deletions(-)
|
|
|
ba46c7 |
create mode 100644 ldap/admin/src/scripts/60upgradeconfigfiles.pl
|
|
|
ba46c7 |
|
|
|
ba46c7 |
diff --git a/ldap/admin/src/scripts/60upgradeconfigfiles.pl b/ldap/admin/src/scripts/60upgradeconfigfiles.pl
|
|
|
ba46c7 |
new file mode 100644
|
|
|
ba46c7 |
index 0000000..4b37353
|
|
|
ba46c7 |
--- /dev/null
|
|
|
ba46c7 |
+++ b/ldap/admin/src/scripts/60upgradeconfigfiles.pl
|
|
|
ba46c7 |
@@ -0,0 +1,69 @@
|
|
|
ba46c7 |
+use File::Copy;
|
|
|
ba46c7 |
+use Mozilla::LDAP::LDIF;
|
|
|
ba46c7 |
+use DSCreate qw(installSchema);
|
|
|
ba46c7 |
+
|
|
|
ba46c7 |
+sub runinst {
|
|
|
ba46c7 |
+ my ($inf, $inst, $dseldif, $conn) = @_;
|
|
|
ba46c7 |
+
|
|
|
ba46c7 |
+ if (!$inf->{slapd}->{config_dir} or (! -d $inf->{slapd}->{config_dir})) {
|
|
|
ba46c7 |
+ return ('error_reading_config_dir', $inf->{slapd}->{config_dir});
|
|
|
ba46c7 |
+ }
|
|
|
ba46c7 |
+
|
|
|
ba46c7 |
+ # these files are obsolete, or we want to replace
|
|
|
ba46c7 |
+ # them with newer versions
|
|
|
ba46c7 |
+ my @toremove = qw(slapd-collations.conf);
|
|
|
ba46c7 |
+
|
|
|
ba46c7 |
+ # make a backup directory to store the deleted config file, then
|
|
|
ba46c7 |
+ # don't really delete it, just move it to that directory
|
|
|
ba46c7 |
+ my $mode = (stat($inf->{slapd}->{config_dir}))[2];
|
|
|
ba46c7 |
+ my $bakdir = $inf->{slapd}->{bak_dir} . ".bak";
|
|
|
ba46c7 |
+ if (! -d $bakdir) {
|
|
|
ba46c7 |
+ $! = 0; # clear
|
|
|
ba46c7 |
+ mkdir $bakdir, $mode;
|
|
|
ba46c7 |
+ if ($!) {
|
|
|
ba46c7 |
+ return ('error_creating_directory', $bakdir, $!);
|
|
|
ba46c7 |
+ }
|
|
|
ba46c7 |
+ }
|
|
|
ba46c7 |
+
|
|
|
ba46c7 |
+ my @errs;
|
|
|
ba46c7 |
+ for my $file (@toremove) {
|
|
|
ba46c7 |
+ my $oldname = $inf->{slapd}->{config_dir} . "/" . $file;
|
|
|
ba46c7 |
+ next if (! -f $oldname); # does not exist - skip - already (re)moved
|
|
|
ba46c7 |
+ my $newname = "$bakdir/$file";
|
|
|
ba46c7 |
+ $! = 0; # clear
|
|
|
ba46c7 |
+ rename $oldname, $newname;
|
|
|
ba46c7 |
+ if ($!) {
|
|
|
ba46c7 |
+ push @errs, ["error_renaming_config", $oldname, $newname, $!];
|
|
|
ba46c7 |
+ }
|
|
|
ba46c7 |
+ }
|
|
|
ba46c7 |
+
|
|
|
ba46c7 |
+ my $configsrcdir = $inf->{slapd}->{config_dir} . "/../config";
|
|
|
ba46c7 |
+ for my $file (@toremove) {
|
|
|
ba46c7 |
+ my $srcname = "$configsrcdir/$file";
|
|
|
ba46c7 |
+ my $newname = $inf->{slapd}->{config_dir} . "/" . $file;
|
|
|
ba46c7 |
+
|
|
|
ba46c7 |
+ copy $srcname, $newname;
|
|
|
ba46c7 |
+ if ($!) {
|
|
|
ba46c7 |
+ push @errs, ["error_renaming_config", $srcname, $newname, $!];
|
|
|
ba46c7 |
+ }
|
|
|
ba46c7 |
+ }
|
|
|
ba46c7 |
+
|
|
|
ba46c7 |
+ # If we've encountered any errors up to this point, restore
|
|
|
ba46c7 |
+ # the original file.
|
|
|
ba46c7 |
+ if (@errs) {
|
|
|
ba46c7 |
+ # restore the original files
|
|
|
ba46c7 |
+ for my $file (@toremove) {
|
|
|
ba46c7 |
+ my $oldname = "$bakdir/$file";
|
|
|
ba46c7 |
+ next if (! -f $oldname); # does not exist - not backed up
|
|
|
ba46c7 |
+ my $newname = $inf->{slapd}->{config_dir} . "/" . $file;
|
|
|
ba46c7 |
+ next if (-f $newname); # not removed
|
|
|
ba46c7 |
+ rename $oldname, $newname;
|
|
|
ba46c7 |
+ }
|
|
|
ba46c7 |
+ return @errs;
|
|
|
ba46c7 |
+ }
|
|
|
ba46c7 |
+
|
|
|
ba46c7 |
+ if (-d $bakdir) {
|
|
|
ba46c7 |
+ system("rm -rf $bakdir");
|
|
|
ba46c7 |
+ }
|
|
|
ba46c7 |
+ return ();
|
|
|
ba46c7 |
+}
|
|
|
ba46c7 |
--
|
|
|
ba46c7 |
1.7.1
|
|
|
ba46c7 |
|