Merge branch 'master' of https://github.com/EQEmu/Server into bots_updater

This commit is contained in:
Uleat
2015-10-09 21:39:05 -04:00
18 changed files with 367 additions and 315 deletions
+175 -55
View File
@@ -14,6 +14,7 @@ use POSIX qw(strftime);
use File::Path;
use File::Find;
use URI::Escape;
use Time::HiRes qw(usleep);
$time_stamp = strftime('%m-%d-%Y', gmtime());
@@ -22,7 +23,7 @@ if($Config{osname}=~/linux/i){ $OS = "Linux"; }
if($Config{osname}=~/Win|MS/i){ $OS = "Windows"; }
#::: If current version is less than what world is reporting, then download a new one...
$current_version = 10;
$current_version = 11;
if($ARGV[0] eq "V"){
if($ARGV[1] > $current_version){
@@ -49,9 +50,6 @@ no warnings;
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime();
#::: Cleanup staged folder...
rmtree("updates_staged/");
my $confile = "eqemu_config.xml"; #default
open(F, "<$confile");
my $indb = 0;
@@ -103,12 +101,40 @@ if($OS eq "Linux"){
}
#::: Path not found, error and exit
if($path eq ""){
if($path eq ""){
print "MySQL path not found, please add the path for automatic database upgrading to continue... \n\n";
print "script_exiting...\n";
exit;
}
if($ARGV[0] eq "installer"){
print "Running EQEmu Server installer routines...\n";
mkdir('logs');
mkdir('updates_staged');
fetch_latest_windows_binaries();
map_files_fetch_bulk();
opcodes_fetch();
plugins_fetch();
quest_files_fetch();
lua_modules_fetch();
get_remote_file("https://raw.githubusercontent.com/Akkadius/EQEmuInstall/master/lua51.dll", "lua51.dll", 1);
#::: Database Routines
print "MariaDB :: Creating Database 'peq'\n";
print `"$path" --host $host --user $user --password="$pass" -N -B -e "DROP DATABASE peq;CREATE DATABASE peq"`;
if($OS eq "Windows"){ @db_version = split(': ', `world db_version`); }
if($OS eq "Linux"){ @db_version = split(': ', `./world db_version`); }
$bin_db_ver = trim($db_version[1]);
check_db_version_table();
$local_db_ver = trim(get_mysql_result("SELECT version FROM db_version LIMIT 1"));
fetch_peq_db_full();
print "\nFetching Latest Database Updates...\n";
main_db_management();
print "\nApplying Latest Database Updates...\n";
main_db_management();
exit;
}
#::: Create db_update working directory if not created
mkdir('db_update');
@@ -118,15 +144,19 @@ if(trim(get_mysql_result("SHOW COLUMNS FROM db_version LIKE 'Revision'")) ne ""
print "Old db_version table present, dropping...\n\n";
}
if(get_mysql_result("SHOW TABLES LIKE 'db_version'") eq "" && $db){
print get_mysql_result("
CREATE TABLE db_version (
version int(11) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO db_version (version) VALUES ('1000');");
print "Table 'db_version' does not exists.... Creating...\n\n";
sub check_db_version_table{
if(get_mysql_result("SHOW TABLES LIKE 'db_version'") eq "" && $db){
print get_mysql_result("
CREATE TABLE db_version (
version int(11) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO db_version (version) VALUES ('1000');");
print "Table 'db_version' does not exists.... Creating...\n\n";
}
}
check_db_version_table();
if($OS eq "Windows"){ @db_version = split(': ', `world db_version`); }
if($OS eq "Linux"){ @db_version = split(': ', `./world db_version`); }
@@ -184,13 +214,13 @@ sub show_menu_prompt {
1 => \&database_dump,
2 => \&database_dump_compress,
3 => \&main_db_management,
4 => \&aa_fetch,
4 => \&bots_db_management,
5 => \&opcodes_fetch,
6 => \&map_files_fetch,
7 => \&plugins_fetch,
8 => \&quest_files_fetch,
9 => \&lua_modules_fetch,
10 => \&bots_db_management,
10 => \&aa_fetch,
20 => \&do_update_self,
0 => \&script_exit,
);
@@ -241,31 +271,33 @@ sub menu_options {
$bots_management = "Install bots database pre-requisites (Requires bots server binaries)";
}
else{
$bots_management = "Check for Bot pending REQUIRED database updates...";
$bots_management = "Check for Bot pending REQUIRED database updates... (Must have bots enabled)";
}
}
}
else{
$option[3] = "Check and stage pending REQUIRED Database updates";
$bots_management = "Check for Bot REQUIRED database updates...";
$bots_management = "Check for Bot REQUIRED database updates... (Must have bots enabled)";
}
return <<EO_MENU;
EQEmu Update Utility Menu:
1) Backup Database - (Saves to Backups folder)
2) Backup Database Compressed - (Saves to Backups folder)
3) $option[3]
4) AAs - Download Latest AA's from PEQ (This overwrites existing data)
5) OPCodes - Download latest opcodes
6) Maps - Download latest map and water files
7) Plugins - Download latest Perl plugins
8) Quests - Download latest PEQ quests and stage updates
9) LUA Modules - Download latest LUA Modules (Required for Lua)
10) $bots_management
20) Force update this script (Redownload)
0) Exit
Enter numbered option and press enter...
============================================================
#::: EQEmu Update Utility Menu: (eqemu_update.pl)
============================================================
1) [Backup Database] :: (Saves to Backups folder)
2) [Backup Database Compressed] :: (Saves to Backups folder)
3) [EQEmu DB Schema] :: $option[3]
4) [EQEmu DB Bots Schema] $bots_management
5) [OPCodes] :: Download latest opcodes for each EQ Client
6) [Maps] :: Download latest map and water files
7) [Plugins (Perl)] :: Download latest Perl plugins
8) [Quests (Perl/LUA)] :: Download latest PEQ quests and stage updates
9) [LUA Modules] :: Download latest LUA Modules (Required for Lua)
10) [DB Data : Alternate Advancement] :: Download Latest AA's from PEQ (This overwrites existing data)
20) [Update the updater] Force update this script (Redownload)
0) Exit
Enter numbered option and press enter...
EO_MENU
}
@@ -295,7 +327,11 @@ sub database_dump_compress {
print `perl db_dumper.pl database="$db" loc="backups" compress`;
}
sub script_exit{ }
sub script_exit{
#::: Cleanup staged folder...
rmtree("updates_staged/");
exit;
}
#::: Returns Tab Delimited MySQL Result from Command Line
sub get_mysql_result{
@@ -345,35 +381,48 @@ sub get_remote_file{
if($OS eq "Windows"){
#::: For non-text type requests...
if($content_type == 1){
use LWP::Simple qw(getstore);
if(!getstore($URL, $Dest_File)){
print "Error, no connection or failed request...\n\n";
}
else{
print " o URL: (" . $URL . ")\n";
print " o Saved: (" . $Dest_File . ") \n";
$break = 0;
while($break == 0) {
use LWP::Simple qw(getstore);
if(!getstore($URL, $Dest_File)){
# print "Error, no connection or failed request...\n\n";
}
# sleep(1);
#::: Make sure the file exists before continuing...
if(-e $Dest_File) {
$break = 1;
print " [URL] :: " . $URL . "\n";
print " [Saved] :: " . $Dest_File . "\n";
} else { $break = 0; }
usleep(500);
}
}
else{
require LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
my $response = $ua->get($URL);
if ($response->is_success){
open (FILE, '> ' . $Dest_File . '');
print FILE $response->decoded_content;
close (FILE);
print " o URL: (" . $URL . ")\n";
print " o Saved: (" . $Dest_File . ") \n";
}
else {
print "Error, no connection or failed request...\n\n";
$break = 0;
while($break == 0) {
require LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
my $response = $ua->get($URL);
if ($response->is_success){
open (FILE, '> ' . $Dest_File . '');
print FILE $response->decoded_content;
close (FILE);
}
else {
# print "Error, no connection or failed request...\n\n";
}
if(-e $Dest_File) {
$break = 1;
print " [URL] :: " . $URL . "\n";
print " [Saved] :: " . $Dest_File . "\n";
} else { $break = 0; }
usleep(500);
}
}
}
if($OS eq "Linux"){
if($OS eq "Linux"){
#::: wget -O db_update/db_update_manifest.txt https://raw.githubusercontent.com/EQEmu/Server/master/utils/sql/db_update_manifest.txt
$wget = `wget --no-check-certificate --quiet -O $Dest_File $URL`;
print " o URL: (" . $URL . ")\n";
@@ -461,6 +510,75 @@ sub copy_file{
copy $l_source_file, $l_dest_file;
}
sub fetch_latest_windows_binaries{
print "\n --- Fetching Latest Windows Binaries... --- \n";
get_remote_file("https://raw.githubusercontent.com/Akkadius/EQEmuInstall/master/master_windows_build.zip", "updates_staged/master_windows_build.zip", 1);
print "\n --- Fetched Latest Windows Binaries... --- \n";
print "\n --- Extracting... --- \n";
unzip('updates_staged/master_windows_build.zip', 'updates_staged/binaries/');
my @files;
my $start_dir = "updates_staged/binaries";
find(
sub { push @files, $File::Find::name unless -d; },
$start_dir
);
for my $file (@files) {
$dest_file = $file;
$dest_file =~s/updates_staged\/binaries\///g;
print "Installing :: " . $dest_file . "\n";
copy_file($file, $dest_file);
}
print "\n --- Done... --- \n";
rmtree('updates_staged');
}
sub fetch_peq_db_full{
print "Downloading latest PEQ Database... Please wait...\n";
get_remote_file("http://edit.peqtgc.com/weekly/peq_beta.zip", "updates_staged/peq_beta.zip", 1);
print "Downloaded latest PEQ Database... Extracting...\n";
unzip('updates_staged/peq_beta.zip', 'updates_staged/peq_db/');
my $start_dir = "updates_staged\\peq_db";
find(
sub { push @files, $File::Find::name unless -d; },
$start_dir
);
for my $file (@files) {
$dest_file = $file;
$dest_file =~s/updates_staged\\peq_db\///g;
if($file=~/peqbeta|player_tables/i){
print "MariaDB :: Installing :: " . $dest_file . "\n";
get_mysql_result_from_file($file);
}
if($file=~/eqtime/i){
print "Installing eqtime.cfg\n";
copy_file($file, "eqtime.cfg");
}
}
}
sub map_files_fetch_bulk{
print "\n --- Fetching Latest Maps... (This could take a few minutes...) --- \n";
get_remote_file("http://github.com/Akkadius/EQEmuMaps/archive/master.zip", "maps/maps.zip", 1);
unzip('maps/maps.zip', 'maps/');
my @files;
my $start_dir = "maps\\EQEmuMaps-master\\maps";
find(
sub { push @files, $File::Find::name unless -d; },
$start_dir
);
for my $file (@files) {
$dest_file = $file;
$dest_file =~s/maps\\EQEmuMaps-master\\maps\///g;
print "Installing :: " . $dest_file . "\n";
copy_file($file, "maps/" . $new_file);
}
print "\n --- Fetched Latest Maps... --- \n";
rmtree('maps/EQEmuMaps-master');
unlink('maps/maps.zip');
}
sub map_files_fetch{
print "\n --- Fetching Latest Maps --- \n";
@@ -549,6 +667,8 @@ sub quest_files_fetch{
}
}
rmtree('updates_staged');
if($fc == 0){
print "\nNo Quest Updates found... \n\n";
}