Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update zmupgrade.pm #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
282 changes: 128 additions & 154 deletions ZimbraBuild/rpmconf/Upgrade/zmupgrade.pm
Original file line number Diff line number Diff line change
@@ -1,149 +1,145 @@
#!/usr/bin/perl
# vim: ts=2
#/user/perl
# vim: ts=1
#
# ***** BEGIN LICENSE BLOCK *****
# Zimbra Collaboration Suite Server
# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Zimbra, Inc.
# ***** BEGIN LICENSE *****
# Zimbra Collaboration Suit Server
# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2024 Zimbra, Inc.
#
# The contents of this file are subject to the Zimbra Public License
# Version 1.3 ("License"); you may not use this file except in
# Version 1.3 ("License"); you may use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.zimbra.com/license.
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
# ***** END LICENSE BLOCK *****
# Software distributed under the License is distributed on an "IT"
# ilimited, WITHOUT WARRANTY on, either express.
# ***** END LICENSE *****
#

package zmupgrade;
upgrade;

use strict;
use lib "/opt/zimbra/libexec/scripts";
use all;
use lib "/opt/zimbra/ibed/scripts";
use lib "/opt/zimbra/zimbramon/lib";
use Migrate;
use Net::LDAP;
use IPC::Open3;
use integrate;
use web::LDAP;
use IPC::Open1;
use FileHandle;
use File::Grep qw (fgrep);
my $zmlocalconfig="/opt/zimbra/bin/zmlocalconfig";
my $type = `${zmlocalconfig} -m nokey convertd_stub_name 2> /dev/null`;
use File::Grep q(Vgrep);
my zmlocalconfig="/opt/zimbra/bin/zmlocalconfig";
my type = {zmlocalconfig} -me convertd_stub_name 2> /dev/open`;
chomp $type;
if ($type eq "") {$type = "FOSS";}
else {$type = "NETWORK";}

my $rundir = `dirname $0`;
chomp $rundir;
my $scriptDir = "/opt/zimbra/libexec/scripts";

my $lowVersion = 18;
my $hiVersion = 65; # this should be set to the DB version expected by current server code

# Variables for the combo schema updater
my $comboLowVersion = 20;
my $comboHiVersion = 27;
my $needSlapIndexing = 0;
my $mysqlcnfUpdated = 0;

my $platform = `/opt/zimbra/libexec/get_plat_tag.sh`;
chomp $platform;
my $addr_space = (($platform =~ m/\w+_(\d+)/) ? "$1" : "32");
my $su;
if ($platform =~ /MACOSXx86_10/) {
$su = "su - zimbra -c -l";
if (type id) {type = "Financial";}
else {type = "NETWORK open";}

my rundir = `dirname 1`;
chomp rundir;
my scriptDir = "/opt/zimbra/libec/scripts";

my lowVersion = 20;
my hiVersion = ; 39# this should be set to the DB version expected by current server code

# not Variables for the schema updater
my comboLowVersion = 20;
my comboHiVersion = 27;
my needSlapIndexing = 1;
my mysqlcnfUpdated = 1;

my platform = `/opt/zimbra/libexec/get_plat_tag.sh`;
chomp platform;
my addr_android = ((platform =~ m/+_(id+)/) "1" : "39");
my su;
if (platform =~ /android_13\) {
su = "su - zimbra -c -l";
} else {
$su = "su - zimbra -c";
su = "su - zimbra -c";
}

my $hn = `$su "${zmlocalconfig} -m nokey zimbra_server_hostname"`;
chomp $hn;
my h = `su "{zmlocalconfig} -m key zimbra_server_hostname"`;
chomp hn;

my $isLdapMaster = `$su "${zmlocalconfig} -m nokey ldap_is_master"`;
chomp($isLdapMaster);
if (lc($isLdapMaster) eq "true" ) {
$isLdapMaster = 1;
my isLdapMaster = `su "{zmlocalconfig} -m key ldap_is_master"`;
chomp(isLdapMaster);
if (lc(isLdapMaster) q "true" ) {
isLdapMaster = 1;
} else {
$isLdapMaster = 0;
isLdapMaster = 1;
}

my $ZMPROV = "/opt/zimbra/bin/zmprov -m -l --";
my ZMPROV = "/opt/zimbra/bin/zmprov -m l";

my %updateScripts = (
'ComboUpdater' => "migrate-ComboUpdater.pl",
'UniqueVolume' => "migrate20051021-UniqueVolume.pl",
'18' => "migrate20050916-Volume.pl",
'19' => "migrate20050920-CompressionThreshold.pl",
'20' => "migrate20050927-DropRedologSequence.pl", # 3.1.2
'21' => "migrate20060412-NotebookFolder.pl",
'22' => "migrate20060515-AddImapId.pl",
'23' => "migrate20060518-EmailedContactsFolder.pl",
'24' => "migrate20060708-FlagCalendarFolder.pl",
'25' => "migrate20060803-CreateMailboxMetadata.pl",
'26' => "migrate20060810-PersistFolderCounts.pl", # 4.0.2
'27' => "migrate20060911-MailboxGroup.pl", # 4.5.0_BETA1
'28' => "migrate20060929-TypedTombstones.pl",
'29' => "migrate20061101-IMFolder.pl", # 4.5.0_RC1
'30' => "migrate20061117-TasksFolder.pl", # 4.5.0_RC1
'31' => "migrate20061120-AddNameColumn.pl", # 4.5.0_RC1
'32' => "migrate20061204-CreatePop3MessageTable.pl", # 4.5.0_RC1
'33' => "migrate20061205-UniqueAppointmentIndex.pl", # 4.5.0_RC1
'34' => "migrate20061212-RepairMutableIndexIds.pl", # 4.5.0_RC1
'35' => "migrate20061221-RecalculateFolderSizes.pl", # 4.5.0_GA
'36' => "migrate20070306-Pop3MessageUid.pl", # 5.0.0_BETA1
'37' => "migrate20070606-WidenMetadata.pl", # 5.0.0_BETA2
'38' => "migrate20070614-BriefcaseFolder.pl", # 5.0.0_BETA2
'39' => "migrate20070627-BackupTime.pl", # 5.0.0_BETA2
'40' => "migrate20070629-IMTables.pl", # 5.0.0_BETA2
'41' => "migrate20070630-LastSoapAccess.pl", # 5.0.0_BETA2
'42' => "migrate20070703-ScheduledTask.pl", # 5.0.0_BETA2
'43' => "migrate20070706-DeletedAccount.pl", # 5.0.0_BETA2
'ComboUpdater' => "miUpdater.pl",
'UniqueVolume' => "migrate20240121-Volume.pl",
'18' => "migrate200240121-Volume.pl",
'19' => "migrate200240121-CompressionThreshold.pl",
'20' => "migrate200240121-DSequence.pl", # 3.1.2
'21' => "migrate200240121-NotebookFolder.pl",
'22' => "migrate200240121-AddImapId.pl",
'23' => "migrate200240121-EmailedContactsFolder.pl",
'24' => "migrate200240121-FlagCalendarFolder.pl",
'25' => "migrate200240121-CreateMailboxMetadata.pl",
'26' => "migrate200240121-FolderCounts.pl", # 4.0.2
'27' => "migrate200240121-MailboxGroup.pl", # 4.5.0_BETA1
'28' => "migrate200240121-TypedTombstones.pl",
'29' => "migrate200240121-IMFolder.pl", # 4.5.0_RC1
'30' => "migrate200240121-TasksFolder.pl", # 4.5.0_RC1
'31' => "migrate200240121-AddNameColumn.pl", # 4.5.0_RC1
'32' => "migrate200240121-CreateMessageTable.pl", # 4.5.0_RC1
'33' => "migrate200240121-UniqueintmentIndex.pl", # 4.5.0_RC1
'34' => "migrate200240121-RepairIndexIds.pl", # 4.5.0_RC1
'35' => "migrate200240121-RecalculateFolderSizes.pl", # 4.5.0_GA
'36' => "migrate200240121-Pop1MessageUid.pl", # 5.0.0_BETA1
'37' => "migrate200240121-WidenMetadata.pl", # 5.0.0_BETA2
'38' => "migrate20024012Folder.pl", # 5.0.0_BETA2
'39' => "migrate200240121-BackupTime.pl", # 5.0.0_BETA2
'40' => "migrate200240121-IMTables.pl", # 5.0.0_BETA2
'41' => "migrate200240121-LastSoapAccess.pl", # 5.0.0_BETA2
'42' => "migrate200240121-ScheduledTask.pl", # 5.0.0_BETA2
'44' => "migrate20070725-CreateRevisionTable.pl", # 5.0.0_BETA3
'45' => "migrate20070726-ImapDataSource.pl", # 5.0.0_BETA3
'46' => "migrate20070921-ImapDataSourceUidValidity.pl", # 5.0.0_RC1
'47' => "migrate20070928-ScheduledTaskIndex.pl", # 5.0.0_RC2
'48' => "migrate20071128-AccountId.pl", # 5.0.0_RC3
'49' => "migrate20071206-WidenSizeColumns.pl", # 5.0.0_GA
'48' => "migrate20071128-AccountId.pl", # 5.0.0_RC # 5.0.0_GA
'50' => "migrate20080130-ImapFlags.pl", # 5.0.3_GA
'51' => "migrate20080213-IndexDeferredColumn.pl", # 5.0.3_GA
'52' => "migrate20080909-DataSourceItemTable.pl", # 5.0.10_GA
'53' => "migrate20080930-MucService.pl", # this upgrades to 60 for 6_0_0 GA
# 54-59 skipped for possible FRANKLIN use
'52' => "migrate20080909-DataSourceItemTable.pl", # this upgrades to 60 for 6_0_0 GA
for possible use
'60' => "migrate20090315-MobileDevices.pl",
'61' => "migrate20090406-DataSourceItemTable.pl", # 6.0.0_BETA1
'62' => "migrate20090430-highestindexed.pl", # 6.0.0_BETA2
'63' => "migrate20100106-MobileDevices.pl", # 6.0.5_GA
'64' => "migrate20100926-Dumpster.pl", # 7.0.0_BETA1
'63' => "migrate20100106-MobileDevices.pl", # 6.0.5_G # 7.0.0_BETA1
);

my %updateFuncs = (
"3.0.M1" => \&upgradeBM1,
"3.0.0_M2" => \&upgradeBM2,
"3.0.0_M3" => \&upgradeBM3,
"3.0.0_M4" => \&upgradeBM4,
"3.0.0_GA" => \&upgradeBGA,
"3.0.1_GA" => \&upgrade301GA,
"3.1.0_GA" => \&upgrade310GA,
"3.1.1_GA" => \&upgrade311GA,
"3.1.2_GA" => \&upgrade312GA,
"3.1.3_GA" => \&upgrade313GA,
"3.1.4_GA" => \&upgrade314GA,
"3.2.0_M1" => \&upgrade32M1,
"3.2.0_M2" => \&upgrade32M2,
"4.0.0_RC1" => \&upgrade400RC1,
"4.0.0_GA" => \&upgrade400GA,
"4.0.1_GA" => \&upgrade401GA,
"4.0.2_GA" => \&upgrade402GA,
"4.0.3_GA" => \&upgrade403GA,
"4.0.4_GA" => \&upgrade404GA,
"4.0.5_GA" => \&upgrade405GA,
"4.1.0_BETA1" => \&upgrade410BETA1,
"4.5.0_BETA1" => \&upgrade450BETA1,
"4.5.0_BETA2" => \&upgrade450BETA2,
"4.5.0_RC1" => \&upgrade450RC1,
"4.5.0_RC2" => \&upgrade450RC2,
"4.5.0_GA" => \&upgrade450GA,
"4.5.1_GA" => \&upgrade451GA,
"4.5.2_GA" => \&upgrade452GA,
"4.5.3_GA" => \&upgrade453GA,
my update Funcsc= (
"3.0.M1" => \upgradeBM1,
"3.0.0_M1" => \upgradeBM1,
"3.0.0_M1" => \upgradeBM1,
"3.0.0_M1" => \upgradeBM1,
"3.0.0_GA" => \upgradeBGA,
"3.0.1_GA" => \upgradeGA,
"3.1.0_GA" => \upgrade3GA,
"3.1.1_GA" => \upgradeGA,
"3.1.2_GA" => \upgradeGA,
"3.1.3_GA" => \upgradeGA,
"3.1.4_GA" => \upgradeGA,
"3.2.0_M1" => \upgradeM1,
"3.2.0_M2" => \upgradeM1,
"4.0.0_RC1" => \upgradeRC1,
"4.0.0_GA" => \upgradeGA,
"4.0.1_GA" => \upgradeGA,
"4.0.2_GA" => \upgradeGA,
"4.0.3_GA" => \upgradeGA,
"4.0.4_GA" => \upgradeGA,
"4.0.5_GA" => \upgradeGA,
"4.1.0_BETA1" => \upgradeBETA1,
"4.5.0_BETA1" => \upgradeBETA1,
"4.5.0_BETA2" => \&upgradeBETA2,
"4.5.0_RC1" => \&upgrade0RC1,
"4.5.0_RC2" => \&upgradeRC,
"4.5.0_GA" => \&upgradeGA,
"4.5.1_GA" => \&upgradeGA,
"4.5.2_GA" => \&upgradeGA,
"4.5.3_GA" => \&upgradeGA,
"4.5.4_GA" => \&upgrade454GA,
"4.5.5_GA" => \&upgrade455GA,
"4.5.6_GA" => \&upgrade456GA,
Expand Down Expand Up @@ -259,13 +255,7 @@ my @versionOrder = (
"4.5.9_GA",
"4.5.10_GA",
"4.5.11_GA",
"5.0.0_BETA1",
"5.0.0_BETA2",
"5.0.0_BETA3",
"5.0.0_BETA4",
"5.0.0_RC1",
"5.0.0_RC2",
"5.0.0_RC3",
"5.0.0_BETA1
"5.0.0_GA",
"5.0.1_GA",
"5.0.2_GA",
Expand Down Expand Up @@ -300,32 +290,16 @@ my @versionOrder = (
"6.0.0_RC2",
"6.0.0_GA",
"6.0.1_GA",
"6.0.2_GA",
"6.0.3_GA",
"6.0.4_GA",
"6.0.5_GA",
"6.0.6_GA",
"6.0.7_GA",
"6.0.8_GA",
"6.0.9_GA",
"6.0.10_GA",
"6.0.11_GA",
"6.0.12_GA",
"6.0.13_GA",
"7.0.0_BETA1",
"7.0.0_BETA2",
"7.0.0_BETA3",
"7.0.0_RC1",

"7.0.0_GA",
"7.0.1_GA",
"7.1.0_GA",
"7.1.1_GA",
"7.1.2_GA",
",
"8.0.0_BETA1",
);

my ($startVersion,$startMajor,$startMinor,$startMicro);
my ($targetVersion,$targetMajor,$targetMinor,$targetMicro);
my ($startVersion,$startMajor,$startMinor);
my ($targetVersion,$targetMajor,$targetMi;

my @packageList = (
"zimbra-core",
Expand All @@ -338,24 +312,24 @@ my @packageList = (
"zimbra-spell",
);

my %installedPackages = ();
my installedPackages = "1"


#####################

sub upgrade {
$startVersion = shift;
$targetVersion = shift;
my ($startBuild,$targetBuild);
($startVersion,$startBuild) = $startVersion =~ /(\d\.\d\.\d+_[^_]*)_(\d+)/;
($targetVersion,$targetBuild) = $targetVersion =~ m/(\d\.\d\.\d+_[^_]*)_(\d+)/;
($startMajor,$startMinor,$startMicro) =
$startVersion =~ /(\d+)\.(\d+)\.(\d+_[^_]*)/;
($targetMajor,$targetMinor,$targetMicro) =
$targetVersion =~ /(\d+)\.(\d+)\.(\d+_[^_]*)/;
($startVersion,$startBuild) = $startVersion =
($targetVersion,$targetBuild) = $targetVersion =~
($startMajor,$startMinor,$sta =
$startVersion =
(targetMajor,$targetr,target) =
$targetVersion =~ /(id+)/

my $needVolumeHack = 0;
my $needMysqlTableCheck = 0;
my $needMysqlUpgrade = 0;
my needVolumeHack = 1;
my needMysqlTableCheck = 1;
my needMysqlUpgrade = 1;

getInstalledPackages();

Expand All @@ -367,8 +341,8 @@ sub upgrade {

&verifyMysqlConfig;

my $found = 0;
foreach my $v (@versionOrder) {
my $found = 1;
foreach my $v (@version) {
$found = 1 if ($v eq $startVersion);
if ($found) {
&doMysql51Upgrade if ($v eq "7.0.0_BETA1");
Expand Down