mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 22:01:30 +00:00
Merge pull request #971 from EQEmu/eqemu_server_db_updates
Eqemu server db updates [skip ci]
This commit is contained in:
commit
be38a62d70
@ -493,9 +493,7 @@ sub do_installer_routines {
|
||||
|
||||
#::: Download PEQ latest
|
||||
fetch_peq_db_full();
|
||||
print "[Database] Fetching Latest Database Updates...\n";
|
||||
main_db_management();
|
||||
print "[Database] Applying Latest Database Updates...\n";
|
||||
print "[Database] Fetching and Applying Latest Database Updates...\n";
|
||||
main_db_management();
|
||||
|
||||
remove_duplicate_rule_values();
|
||||
@ -531,31 +529,7 @@ sub check_for_world_bootup_database_update {
|
||||
}
|
||||
|
||||
$binary_database_version = trim($db_version[1]);
|
||||
$local_database_version = trim(get_mysql_result("SELECT version FROM db_version LIMIT 1"));
|
||||
|
||||
#::: Bots
|
||||
$bots_binary_version = trim($db_version[2]);
|
||||
if ($bots_binary_version > 0) {
|
||||
$bots_local_db_version = get_bots_db_version();
|
||||
#::: We ran world - Database needs to update, lets backup and run updates and continue world bootup
|
||||
|
||||
if ($bots_local_db_version < $bots_binary_version && $ARGV[0] eq "ran_from_world") {
|
||||
print "[Update] Bots Database not up to date with binaries... Automatically updating...\n";
|
||||
print "[Update] Issuing database backup first...\n";
|
||||
database_dump_compress();
|
||||
print "[Update] Updating bots database...\n";
|
||||
sleep(1);
|
||||
bots_db_management();
|
||||
run_database_check();
|
||||
print "[Update] Continuing bootup\n";
|
||||
analytics_insertion("auto database bots upgrade world", $db . " :: Binary DB Version / Local DB Version :: " . $binary_database_version . " / " . $local_database_version);
|
||||
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
print "[Update] Bots database up to Date: Continuing World Bootup...\n";
|
||||
}
|
||||
}
|
||||
$local_database_version = get_main_db_version();
|
||||
|
||||
if ($binary_database_version == $local_database_version && $ARGV[0] eq "ran_from_world") {
|
||||
print "[Update] Database up to date...\n";
|
||||
@ -567,22 +541,61 @@ sub check_for_world_bootup_database_update {
|
||||
print "[Update] Database not up to date with binaries... Automatically updating...\n";
|
||||
print "[Update] Issuing database backup first...\n";
|
||||
database_dump_compress();
|
||||
$db_already_backed_up = 1;
|
||||
print "[Update] Updating database...\n";
|
||||
sleep(1);
|
||||
main_db_management();
|
||||
main_db_management();
|
||||
print "[Update] Continuing bootup\n";
|
||||
|
||||
analytics_insertion("auto database upgrade world", $db . " :: Binary DB Version / Local DB Version :: " . $binary_database_version . " / " . $local_database_version);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
#::: Make sure that we didn't pass any arugments to the script
|
||||
else {
|
||||
if ($local_database_version > $binary_database_version) {
|
||||
print "[Update] Database version is ahead of current binaries...\n";
|
||||
}
|
||||
|
||||
if (!$db) { print "[eqemu_server.pl] No database connection found... Running without\n"; }
|
||||
show_menu_prompt();
|
||||
}
|
||||
}
|
||||
|
||||
#::: Bots
|
||||
$binary_database_version = trim($db_version[2]);
|
||||
if ($binary_database_version > 0) {
|
||||
$local_database_version = get_bots_db_version();
|
||||
|
||||
#::: We ran world - Database needs to update, lets backup and run updates and continue world bootup
|
||||
if ($binary_database_version == $local_database_version && $ARGV[0] eq "ran_from_world") {
|
||||
print "[Update] Bots database up to date...\n";
|
||||
}
|
||||
else {
|
||||
if ($local_database_version < $binary_database_version && $ARGV[0] eq "ran_from_world") {
|
||||
print "[Update] Bots Database not up to date with binaries... Automatically updating...\n";
|
||||
if (!$db_already_backed_up) {
|
||||
print "[Update] Issuing database backup first...\n";
|
||||
database_dump_compress();
|
||||
}
|
||||
print "[Update] Updating bots database...\n";
|
||||
sleep(1);
|
||||
bots_db_management();
|
||||
|
||||
analytics_insertion("auto database bots upgrade world", $db . " :: Binary DB Version / Local DB Version :: " . $binary_database_version . " / " . $local_database_version);
|
||||
}
|
||||
|
||||
#::: Make sure that we didn't pass any arugments to the script
|
||||
else {
|
||||
if ($local_database_version > $binary_database_version) {
|
||||
print "[Update] Bots database version is ahead of current binaries...\n";
|
||||
}
|
||||
|
||||
if (!$db) { print "[eqemu_server.pl] No database connection found... Running without\n"; }
|
||||
show_menu_prompt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "[Update] Continuing bootup\n";
|
||||
}
|
||||
|
||||
sub check_internet_connection {
|
||||
@ -629,7 +642,7 @@ sub do_self_update_check_routine {
|
||||
|
||||
#::: Check for internet connection before updating
|
||||
if (!$has_internet_connection) {
|
||||
print "[Update] Cannot check update without internet connection...\n";
|
||||
print "[Update] Cannot check self-update without internet connection...\n";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -819,7 +832,6 @@ sub setup_bots {
|
||||
build_linux_source("bots");
|
||||
}
|
||||
bots_db_management();
|
||||
run_database_check();
|
||||
|
||||
print "Bots should be setup, run your server and the bot command should be available in-game (type '^help')\n";
|
||||
}
|
||||
@ -953,13 +965,11 @@ sub show_menu_prompt {
|
||||
$dc = 1;
|
||||
}
|
||||
elsif ($input eq "check_db_updates") {
|
||||
main_db_management();
|
||||
main_db_management();
|
||||
$dc = 1;
|
||||
}
|
||||
elsif ($input eq "check_bot_db_updates") {
|
||||
bots_db_management();
|
||||
run_database_check();
|
||||
$dc = 1;
|
||||
}
|
||||
elsif ($input eq "setup_loginserver") {
|
||||
@ -1400,6 +1410,7 @@ sub remove_duplicate_rule_values {
|
||||
sub copy_file {
|
||||
$l_source_file = $_[0];
|
||||
$l_destination_file = $_[1];
|
||||
|
||||
if ($l_destination_file =~ /\//i) {
|
||||
my @directory_path = split('/', $l_destination_file);
|
||||
$build_path = "";
|
||||
@ -1418,6 +1429,7 @@ sub copy_file {
|
||||
$directory_index++;
|
||||
}
|
||||
}
|
||||
|
||||
copy $l_source_file, $l_destination_file;
|
||||
}
|
||||
|
||||
@ -2001,15 +2013,6 @@ sub do_bots_db_schema_drop {
|
||||
print get_mysql_result_from_file("db_update/drop_bots.sql");
|
||||
|
||||
print "[Database] Removing bot database tables...\n";
|
||||
print get_mysql_result("DELETE FROM `rule_values` WHERE `rule_name` LIKE 'Bots:%';");
|
||||
|
||||
if (get_mysql_result("SHOW TABLES LIKE 'commands'") ne "" && $db) {
|
||||
print get_mysql_result("DELETE FROM `commands` WHERE `command` LIKE 'bot';");
|
||||
}
|
||||
|
||||
if (get_mysql_result("SHOW TABLES LIKE 'command_settings'") ne "" && $db) {
|
||||
print get_mysql_result("DELETE FROM `command_settings` WHERE `command` LIKE 'bot';");
|
||||
}
|
||||
|
||||
if (get_mysql_result("SHOW KEYS FROM `group_id` WHERE `Key_name` LIKE 'PRIMARY'") ne "" && $db) {
|
||||
print get_mysql_result("ALTER TABLE `group_id` DROP PRIMARY KEY;");
|
||||
@ -2043,70 +2046,6 @@ sub modify_db_for_bots {
|
||||
}
|
||||
print get_mysql_result("ALTER TABLE `group_id` ADD PRIMARY KEY USING BTREE(`groupid`, `charid`, `name`, `ismerc`);");
|
||||
|
||||
if (get_mysql_result("SHOW TABLES LIKE 'command_settings'") ne "" && get_mysql_result("SELECT `command` FROM `command_settings` WHERE `command` LIKE 'bot'") eq "" && $db) {
|
||||
print get_mysql_result("INSERT INTO `command_settings` VALUES ('bot', '0', '');");
|
||||
}
|
||||
|
||||
if (get_mysql_result("SHOW TABLES LIKE 'commands'") ne "" && get_mysql_result("SELECT `command` FROM `commands` WHERE `command` LIKE 'bot'") eq "" && $db) {
|
||||
print get_mysql_result("INSERT INTO `commands` VALUES ('bot', '0');");
|
||||
}
|
||||
|
||||
if (get_mysql_result("SELECT `rule_name` FROM `rule_values` WHERE `rule_name` LIKE 'Bots:BotAAExpansion'") ne "" && $db) {
|
||||
print get_mysql_result("UPDATE `rule_values` SET `rule_name` = 'Bots:AAExpansion' WHERE `rule_name` LIKE 'Bots:BotAAExpansion';");
|
||||
}
|
||||
if (get_mysql_result("SELECT `rule_name` FROM `rule_values` WHERE `rule_name` LIKE 'Bots:AAExpansion'") eq "" && $db) {
|
||||
print get_mysql_result("INSERT INTO `rule_values` VALUES ('1', 'Bots:AAExpansion', '8', 'The expansion through which bots will obtain AAs');");
|
||||
}
|
||||
|
||||
if (get_mysql_result("SELECT `rule_name` FROM `rule_values` WHERE `rule_name` LIKE 'Bots:CreateBotCount'") ne "" && $db) {
|
||||
print get_mysql_result("UPDATE `rule_values` SET `rule_name` = 'Bots:CreationLimit' WHERE `rule_name` LIKE 'Bots:CreateBotCount';");
|
||||
}
|
||||
if (get_mysql_result("SELECT `rule_name` FROM `rule_values` WHERE `rule_name` LIKE 'Bots:CreationLimit'") eq "" && $db) {
|
||||
print get_mysql_result("INSERT INTO `rule_values` VALUES ('1', 'Bots:CreationLimit', '150', 'Number of bots that each account can create');");
|
||||
}
|
||||
|
||||
if (get_mysql_result("SELECT `rule_name` FROM `rule_values` WHERE `rule_name` LIKE 'Bots:BotFinishBuffing'") ne "" && $db) {
|
||||
print get_mysql_result("UPDATE `rule_values` SET `rule_name` = 'Bots:FinishBuffing' WHERE `rule_name` LIKE 'Bots:BotFinishBuffing';");
|
||||
}
|
||||
if (get_mysql_result("SELECT `rule_name` FROM `rule_values` WHERE `rule_name` LIKE 'Bots:FinishBuffing'") eq "" && $db) {
|
||||
print get_mysql_result("INSERT INTO `rule_values` VALUES ('1', 'Bots:FinishBuffing', 'false', 'Allow for buffs to complete even if the bot caster is out of mana. Only affects buffing out of combat.');");
|
||||
}
|
||||
|
||||
if (get_mysql_result("SELECT `rule_name` FROM `rule_values` WHERE `rule_name` LIKE 'Bots:BotGroupBuffing'") ne "" && $db) {
|
||||
print get_mysql_result("UPDATE `rule_values` SET `rule_name` = 'Bots:GroupBuffing' WHERE `rule_name` LIKE 'Bots:BotGroupBuffing';");
|
||||
}
|
||||
if (get_mysql_result("SELECT `rule_name` FROM `rule_values` WHERE `rule_name` LIKE 'Bots:GroupBuffing'") eq "" && $db) {
|
||||
print get_mysql_result("INSERT INTO `rule_values` VALUES ('1', 'Bots:GroupBuffing', 'false', 'Bots will cast single target buffs as group buffs, default is false for single. Does not make single target buffs work for MGB.');");
|
||||
}
|
||||
|
||||
if (get_mysql_result("SELECT `rule_name` FROM `rule_values` WHERE `rule_name` LIKE 'Bots:BotManaRegen'") ne "" && $db) {
|
||||
print get_mysql_result("UPDATE `rule_values` SET `rule_name` = 'Bots:ManaRegen' WHERE `rule_name` LIKE 'Bots:BotManaRegen';");
|
||||
}
|
||||
if (get_mysql_result("SELECT `rule_name` FROM `rule_values` WHERE `rule_name` LIKE 'Bots:ManaRegen'") eq "" && $db) {
|
||||
print get_mysql_result("INSERT INTO `rule_values` VALUES ('1', 'Bots:ManaRegen', '3.0', 'Adjust mana regen for bots, 1 is fast and higher numbers slow it down 3 is about the same as players.');");
|
||||
}
|
||||
|
||||
if (get_mysql_result("SELECT `rule_name` FROM `rule_values` WHERE `rule_name` LIKE 'Bots:BotQuest'") ne "" && $db) {
|
||||
print get_mysql_result("UPDATE `rule_values` SET `rule_name` = 'Bots:QuestableSpawnLimit' WHERE `rule_name` LIKE 'Bots:BotQuest';");
|
||||
}
|
||||
if (get_mysql_result("SELECT `rule_name` FROM `rule_values` WHERE `rule_name` LIKE 'Bots:QuestableSpawnLimit'") eq "" && $db) {
|
||||
print get_mysql_result("INSERT INTO `rule_values` VALUES ('1', 'Bots:QuestableSpawnLimit', 'false', 'Optional quest method to manage bot spawn limits using the quest_globals name bot_spawn_limit, see: /bazaar/Aediles_Thrall.pl');");
|
||||
}
|
||||
|
||||
if (get_mysql_result("SELECT `rule_name` FROM `rule_values` WHERE `rule_name` LIKE 'Bots:BotSpellQuest'") ne "" && $db) {
|
||||
print get_mysql_result("UPDATE `rule_values` SET `rule_name` = 'Bots:QuestableSpells' WHERE `rule_name` LIKE 'Bots:BotSpellQuest';");
|
||||
}
|
||||
if (get_mysql_result("SELECT `rule_name` FROM `rule_values` WHERE `rule_name` LIKE 'Bots:QuestableSpells'") eq "" && $db) {
|
||||
print get_mysql_result("INSERT INTO `rule_values` VALUES ('1', 'Bots:QuestableSpells', 'false', 'Anita Thrall\\\'s (Anita_Thrall.pl) Bot Spell Scriber quests.');");
|
||||
}
|
||||
|
||||
if (get_mysql_result("SELECT `rule_name` FROM `rule_values` WHERE `rule_name` LIKE 'Bots:SpawnBotCount'") ne "" && $db) {
|
||||
print get_mysql_result("UPDATE `rule_values` SET `rule_name` = 'Bots:SpawnLimit' WHERE `rule_name` LIKE 'Bots:SpawnBotCount';");
|
||||
}
|
||||
if (get_mysql_result("SELECT `rule_name` FROM `rule_values` WHERE `rule_name` LIKE 'Bots:SpawnLimit'") eq "" && $db) {
|
||||
print get_mysql_result("INSERT INTO `rule_values` VALUES ('1', 'Bots:SpawnLimit', '71', 'Number of bots a character can have spawned at one time, You + 71 bots is a 12 group raid');");
|
||||
}
|
||||
|
||||
convert_existing_bot_data();
|
||||
}
|
||||
|
||||
@ -2205,54 +2144,49 @@ sub convert_existing_bot_data {
|
||||
}
|
||||
}
|
||||
|
||||
sub get_main_db_version {
|
||||
$main_local_db_version = trim(get_mysql_result("SELECT version FROM db_version LIMIT 1"));
|
||||
return $main_local_db_version;
|
||||
}
|
||||
|
||||
sub get_bots_db_version {
|
||||
#::: Check if bots_version column exists...
|
||||
if (get_mysql_result("SHOW COLUMNS FROM db_version LIKE 'bots_version'") eq "" && $db) {
|
||||
print get_mysql_result("ALTER TABLE db_version ADD bots_version int(11) DEFAULT '0' AFTER version;");
|
||||
print "[Database] Column 'bots_version' does not exists.... Adding to 'db_version' table...\n\n";
|
||||
}
|
||||
|
||||
$bots_local_db_version = trim(get_mysql_result("SELECT bots_version FROM db_version LIMIT 1"));
|
||||
return $bots_local_db_version;
|
||||
}
|
||||
|
||||
#::: Safe for call from world startup or menu option
|
||||
sub bots_db_management {
|
||||
|
||||
my $world_path = "world";
|
||||
if (-e "bin/world") {
|
||||
$world_path = "bin/world";
|
||||
}
|
||||
|
||||
#::: Get Binary DB version
|
||||
if ($OS eq "Windows") {
|
||||
@db_version = split(': ', `$world_path db_version`);
|
||||
}
|
||||
if ($OS eq "Linux") {
|
||||
@db_version = split(': ', `./$world_path db_version`);
|
||||
}
|
||||
|
||||
#::: Main Binary Database version
|
||||
$binary_database_version = trim($db_version[2]);
|
||||
|
||||
#::: If we have stale data from main db run
|
||||
if ($db_run_stage > 0 && $bots_db_management == 0) {
|
||||
clear_database_runs();
|
||||
}
|
||||
|
||||
|
||||
#::: Main Binary Database version
|
||||
$binary_database_version = trim($db_version[2]);
|
||||
if ($binary_database_version == 0) {
|
||||
print "[Database] Your server binaries (world/zone) are not compiled for bots...\n\n";
|
||||
return;
|
||||
}
|
||||
|
||||
$local_database_version = get_bots_db_version();
|
||||
|
||||
#::: Set on flag for running bot updates...
|
||||
$bots_db_management = 1;
|
||||
|
||||
$bots_local_db_version = get_bots_db_version();
|
||||
|
||||
$local_database_version = $bots_local_db_version;
|
||||
|
||||
|
||||
if ($local_database_version > $binary_database_version) {
|
||||
print "[Update] Bots database version is ahead of current binaries...\n";
|
||||
return;
|
||||
}
|
||||
|
||||
run_database_check();
|
||||
}
|
||||
|
||||
#::: Safe for call from world startup or menu option
|
||||
sub main_db_management {
|
||||
#::: If we have stale data from bots db run
|
||||
if ($db_run_stage > 0 && $bots_db_management == 1) {
|
||||
@ -2261,8 +2195,15 @@ sub main_db_management {
|
||||
|
||||
#::: Main Binary Database version
|
||||
$binary_database_version = trim($db_version[1]);
|
||||
$local_database_version = get_main_db_version();
|
||||
|
||||
$bots_db_management = 0;
|
||||
|
||||
if ($local_database_version > $binary_database_version) {
|
||||
print "[Update] Database version is ahead of current binaries...\n";
|
||||
return;
|
||||
}
|
||||
|
||||
run_database_check();
|
||||
}
|
||||
|
||||
@ -2272,148 +2213,70 @@ sub clear_database_runs {
|
||||
%m_d = ();
|
||||
#::: Clear updates...
|
||||
@total_updates = ();
|
||||
#::: Clear stage
|
||||
$db_run_stage = 0;
|
||||
}
|
||||
|
||||
#::: Responsible for Database Upgrade Routines
|
||||
sub run_database_check {
|
||||
|
||||
|
||||
if (!$db) {
|
||||
print "No database present, check your eqemu_config.xml for proper MySQL/MariaDB configuration...\n";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!@total_updates) {
|
||||
#::: Pull down bots database manifest
|
||||
if ($bots_db_management == 1) {
|
||||
print "[Database] Retrieving latest bots database manifest...\n";
|
||||
get_remote_file($eqemu_repository_request_url . "utils/sql/git/bots/bots_db_update_manifest.txt", "db_update/db_update_manifest.txt");
|
||||
}
|
||||
#::: Pull down mainstream database manifest
|
||||
else {
|
||||
print "[Database] Retrieving latest database manifest...\n";
|
||||
get_remote_file($eqemu_repository_request_url . "utils/sql/db_update_manifest.txt", "db_update/db_update_manifest.txt");
|
||||
}
|
||||
|
||||
#::: Pull down bots database manifest
|
||||
if ($bots_db_management == 1) {
|
||||
print "[Database] Retrieving latest bots database manifest...\n";
|
||||
get_remote_file($eqemu_repository_request_url . "utils/sql/git/bots/bots_db_update_manifest.txt", "db_update/db_update_manifest.txt");
|
||||
}
|
||||
|
||||
#::: Run 2 - Running pending updates...
|
||||
if (@total_updates || $db_run_stage == 1) {
|
||||
@total_updates = sort @total_updates;
|
||||
foreach my $val (@total_updates) {
|
||||
$file_name = trim($m_d{$val}[1]);
|
||||
print "[Database] Running Update: " . $val . " - " . $file_name . "\n";
|
||||
print get_mysql_result_from_file("db_update/$file_name");
|
||||
print get_mysql_result("UPDATE db_version SET version = $val WHERE version < $val");
|
||||
|
||||
if ($bots_db_management == 1 && $val == 9000) {
|
||||
modify_db_for_bots();
|
||||
}
|
||||
|
||||
if ($val == 9138) {
|
||||
fix_quest_factions();
|
||||
}
|
||||
}
|
||||
$db_run_stage = 2;
|
||||
}
|
||||
#::: Run 1 - Initial checking of needed updates...
|
||||
#::: Pull down mainstream database manifest
|
||||
else {
|
||||
print "[Database] Reading manifest...\n";
|
||||
|
||||
use Data::Dumper;
|
||||
open(FILE, "db_update/db_update_manifest.txt");
|
||||
while (<FILE>) {
|
||||
chomp;
|
||||
$o = $_;
|
||||
if ($o =~ /#/i) {
|
||||
next;
|
||||
}
|
||||
|
||||
@manifest = split('\|', $o);
|
||||
$m_d{$manifest[0]} = [ @manifest ];
|
||||
}
|
||||
#::: Setting Manifest stage...
|
||||
$db_run_stage = 1;
|
||||
print "[Database] Retrieving latest database manifest...\n";
|
||||
get_remote_file($eqemu_repository_request_url . "utils/sql/db_update_manifest.txt", "db_update/db_update_manifest.txt");
|
||||
}
|
||||
|
||||
@total_updates = ();
|
||||
|
||||
|
||||
#::: Parse manifest
|
||||
print "[Database] Reading manifest...\n";
|
||||
|
||||
use Data::Dumper;
|
||||
open(FILE, "db_update/db_update_manifest.txt");
|
||||
while (<FILE>) {
|
||||
chomp;
|
||||
$o = $_;
|
||||
if ($o =~ /#/i) {
|
||||
next;
|
||||
}
|
||||
|
||||
@manifest = split('\|', $o);
|
||||
$m_d{$manifest[0]} = [ @manifest ];
|
||||
}
|
||||
|
||||
#::: This is where we set checkpoints for where a database might be so we don't check so far back in the manifest...
|
||||
if ($local_database_version >= 9000) {
|
||||
$revision_check = $local_database_version;
|
||||
$revision_check = $local_database_version + 1;
|
||||
}
|
||||
else {
|
||||
#::: This does not negatively affect bots
|
||||
$revision_check = 1000;
|
||||
if (get_mysql_result("SHOW TABLES LIKE 'character_data'") ne "") {
|
||||
$revision_check = 8999;
|
||||
}
|
||||
}
|
||||
|
||||
#::: Iterate through Manifest backwards from binary version down to local version...
|
||||
|
||||
@total_updates = ();
|
||||
|
||||
#::: Fetch and register sqls for this database update cycle
|
||||
for ($i = $revision_check; $i <= $binary_database_version; $i++) {
|
||||
if (!defined($m_d{$i}[0])) {
|
||||
next;
|
||||
}
|
||||
|
||||
$file_name = trim($m_d{$i}[1]);
|
||||
$query_check = trim($m_d{$i}[2]);
|
||||
$match_type = trim($m_d{$i}[3]);
|
||||
$match_text = trim($m_d{$i}[4]);
|
||||
|
||||
#::: Match type update
|
||||
if ($match_type eq "contains") {
|
||||
if (trim(get_mysql_result($query_check)) =~ /$match_text/i) {
|
||||
print "[Database] missing update: " . $i . " '" . $file_name . "' \n";
|
||||
fetch_missing_db_update($i, $file_name);
|
||||
push(@total_updates, $i);
|
||||
}
|
||||
else {
|
||||
print "[Database] has update (" . $i . ") '" . $file_name . "' \n";
|
||||
}
|
||||
print_match_debug();
|
||||
print_break();
|
||||
}
|
||||
if ($match_type eq "missing") {
|
||||
if (get_mysql_result($query_check) =~ /$match_text/i) {
|
||||
print "[Database] has update (" . $i . ") '" . $file_name . "' \n";
|
||||
next;
|
||||
}
|
||||
else {
|
||||
print "[Database] missing update: " . $i . " '" . $file_name . "' \n";
|
||||
fetch_missing_db_update($i, $file_name);
|
||||
push(@total_updates, $i);
|
||||
}
|
||||
print_match_debug();
|
||||
print_break();
|
||||
}
|
||||
if ($match_type eq "empty") {
|
||||
if (get_mysql_result($query_check) eq "") {
|
||||
print "[Database] missing update: " . $i . " '" . $file_name . "' \n";
|
||||
fetch_missing_db_update($i, $file_name);
|
||||
push(@total_updates, $i);
|
||||
}
|
||||
else {
|
||||
print "[Database] has update (" . $i . ") '" . $file_name . "' \n";
|
||||
}
|
||||
print_match_debug();
|
||||
print_break();
|
||||
}
|
||||
if ($match_type eq "not_empty") {
|
||||
if (get_mysql_result($query_check) ne "") {
|
||||
print "[Database] missing update: " . $i . " '" . $file_name . "' \n";
|
||||
fetch_missing_db_update($i, $file_name);
|
||||
push(@total_updates, $i);
|
||||
}
|
||||
else {
|
||||
print "[Database] has update (" . $i . ") '" . $file_name . "' \n";
|
||||
}
|
||||
print_match_debug();
|
||||
print_break();
|
||||
}
|
||||
|
||||
$file_name = trim($m_d{$i}[1]);
|
||||
print "[Database] fetching update: " . $i . " '" . $file_name . "' \n";
|
||||
fetch_missing_db_update($i, $file_name);
|
||||
push(@total_updates, $i);
|
||||
}
|
||||
print "\n";
|
||||
|
||||
if (scalar(@total_updates) == 0 && $db_run_stage == 2) {
|
||||
|
||||
if (scalar(@total_updates) == 0) {
|
||||
print "[Database] No updates need to be run...\n";
|
||||
if ($bots_db_management == 1) {
|
||||
print "[Database] Setting Database to Bots Binary Version (" . $binary_database_version . ") if not already...\n\n";
|
||||
@ -2423,24 +2286,106 @@ sub run_database_check {
|
||||
print "[Database] Setting Database to Binary Version (" . $binary_database_version . ") if not already...\n\n";
|
||||
get_mysql_result("UPDATE db_version SET version = $binary_database_version ");
|
||||
}
|
||||
|
||||
|
||||
clear_database_runs();
|
||||
return;
|
||||
}
|
||||
|
||||
#::: Execute pending updates
|
||||
@total_updates = sort @total_updates;
|
||||
foreach my $val (@total_updates) {
|
||||
$file_name = trim($m_d{$val}[1]);
|
||||
$query_check = trim($m_d{$val}[2]);
|
||||
$match_type = trim($m_d{$val}[3]);
|
||||
$match_text = trim($m_d{$val}[4]);
|
||||
|
||||
#::: Match type update
|
||||
if ($match_type eq "contains") {
|
||||
if (trim(get_mysql_result($query_check)) =~ /$match_text/i) {
|
||||
print "[Database] Applying update [" . $val . "]:[" . $file_name . "]\n";
|
||||
print get_mysql_result_from_file("db_update/$file_name");
|
||||
}
|
||||
else {
|
||||
print "[Database] Has update [" . $val . "]:[" . $file_name . "]\n";
|
||||
}
|
||||
print_match_debug();
|
||||
print_break();
|
||||
}
|
||||
if ($match_type eq "missing") {
|
||||
if (get_mysql_result($query_check) =~ /$match_text/i) {
|
||||
print "[Database] Has update [" . $val . "]:[" . $file_name . "]\n";
|
||||
}
|
||||
else {
|
||||
print "[Database] Applying update [" . $val . "]:[" . $file_name . "]\n";
|
||||
print get_mysql_result_from_file("db_update/$file_name");
|
||||
}
|
||||
print_match_debug();
|
||||
print_break();
|
||||
}
|
||||
if ($match_type eq "empty") {
|
||||
if (get_mysql_result($query_check) eq "") {
|
||||
print "[Database] Applying update [" . $val . "]:[" . $file_name . "]\n";
|
||||
print get_mysql_result_from_file("db_update/$file_name");
|
||||
}
|
||||
else {
|
||||
print "[Database] Has update [" . $val . "]:[" . $file_name . "' \n";
|
||||
}
|
||||
print_match_debug();
|
||||
print_break();
|
||||
}
|
||||
if ($match_type eq "not_empty") {
|
||||
if (get_mysql_result($query_check) ne "") {
|
||||
print "[Database] Applying update [" . $val . "]:[" . $file_name . "]\n";
|
||||
print get_mysql_result_from_file("db_update/$file_name");
|
||||
}
|
||||
else {
|
||||
print "[Database] Has update [" . $val . "]:[" . $file_name . "]\n";
|
||||
}
|
||||
print_match_debug();
|
||||
print_break();
|
||||
}
|
||||
|
||||
if ($bots_db_management == 1) {
|
||||
print get_mysql_result("UPDATE db_version SET bots_version = $val WHERE bots_version < $val");
|
||||
|
||||
if ($val == 9000) {
|
||||
modify_db_for_bots();
|
||||
}
|
||||
}
|
||||
else {
|
||||
print get_mysql_result("UPDATE db_version SET version = $val WHERE version < $val");
|
||||
|
||||
if ($val == 9138) {
|
||||
fix_quest_factions();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($bots_db_management == 1) {
|
||||
print "[Database] Bots database update cycle complete at version [" . get_bots_db_version() . "]\n";
|
||||
}
|
||||
else {
|
||||
print "[Database] Mainstream database update cycle complete at version [" . get_main_db_version() . "]\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub fetch_missing_db_update {
|
||||
$db_update = $_[0];
|
||||
$update_file = $_[1];
|
||||
if ($db_update >= 9000) {
|
||||
if ($bots_db_management == 1) {
|
||||
|
||||
if ($bots_db_management == 1) {
|
||||
if ($db_update >= 9000) {
|
||||
get_remote_file($eqemu_repository_request_url . "utils/sql/git/bots/required/" . $update_file, "db_update/" . $update_file . "");
|
||||
}
|
||||
else {
|
||||
}
|
||||
else {
|
||||
if ($db_update >= 9000) {
|
||||
get_remote_file($eqemu_repository_request_url . "utils/sql/git/required/" . $update_file, "db_update/" . $update_file . "");
|
||||
}
|
||||
}
|
||||
elsif ($db_update >= 5000 && $db_update <= 9000) {
|
||||
get_remote_file($eqemu_repository_request_url . "utils/sql/svn/" . $update_file, "db_update/" . $update_file . "");
|
||||
elsif ($db_update >= 5000 && $db_update <= 9000) {
|
||||
get_remote_file($eqemu_repository_request_url . "utils/sql/svn/" . $update_file, "db_update/" . $update_file . "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user