mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-19 12:21:34 +00:00
eqemu_update.pl additions for EQEmu Installer to come [skip ci]
This commit is contained in:
parent
2680fc1a83
commit
ffe1bede52
@ -14,6 +14,7 @@ use POSIX qw(strftime);
|
|||||||
use File::Path;
|
use File::Path;
|
||||||
use File::Find;
|
use File::Find;
|
||||||
use URI::Escape;
|
use URI::Escape;
|
||||||
|
use Time::HiRes qw(usleep);
|
||||||
|
|
||||||
$time_stamp = strftime('%m-%d-%Y', gmtime());
|
$time_stamp = strftime('%m-%d-%Y', gmtime());
|
||||||
|
|
||||||
@ -49,9 +50,6 @@ no warnings;
|
|||||||
|
|
||||||
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime();
|
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime();
|
||||||
|
|
||||||
#::: Cleanup staged folder...
|
|
||||||
rmtree("updates_staged/");
|
|
||||||
|
|
||||||
my $confile = "eqemu_config.xml"; #default
|
my $confile = "eqemu_config.xml"; #default
|
||||||
open(F, "<$confile");
|
open(F, "<$confile");
|
||||||
my $indb = 0;
|
my $indb = 0;
|
||||||
@ -66,16 +64,6 @@ while(<F>) {
|
|||||||
elsif(/<db>(.*)<\/db>/i) { $db = $1; }
|
elsif(/<db>(.*)<\/db>/i) { $db = $1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
if($ARGV[0] eq "installer"){
|
|
||||||
print "Running EQEmu Server installer routines...\n";
|
|
||||||
map_files_fetch_bulk();
|
|
||||||
opcodes_fetch();
|
|
||||||
plugins_fetch();
|
|
||||||
quest_files_fetch();
|
|
||||||
lua_modules_fetch();
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$console_output =
|
$console_output =
|
||||||
"============================================================
|
"============================================================
|
||||||
EQEmu: Automatic Upgrade Check
|
EQEmu: Automatic Upgrade Check
|
||||||
@ -119,6 +107,34 @@ if($path eq ""){
|
|||||||
exit;
|
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
|
#::: Create db_update working directory if not created
|
||||||
mkdir('db_update');
|
mkdir('db_update');
|
||||||
|
|
||||||
@ -128,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";
|
print "Old db_version table present, dropping...\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(get_mysql_result("SHOW TABLES LIKE 'db_version'") eq "" && $db){
|
sub check_db_version_table{
|
||||||
|
if(get_mysql_result("SHOW TABLES LIKE 'db_version'") eq "" && $db){
|
||||||
print get_mysql_result("
|
print get_mysql_result("
|
||||||
CREATE TABLE db_version (
|
CREATE TABLE db_version (
|
||||||
version int(11) DEFAULT '0'
|
version int(11) DEFAULT '0'
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||||
INSERT INTO db_version (version) VALUES ('1000');");
|
INSERT INTO db_version (version) VALUES ('1000');");
|
||||||
print "Table 'db_version' does not exists.... Creating...\n\n";
|
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 "Windows"){ @db_version = split(': ', `world db_version`); }
|
||||||
if($OS eq "Linux"){ @db_version = split(': ', `./world db_version`); }
|
if($OS eq "Linux"){ @db_version = split(': ', `./world db_version`); }
|
||||||
|
|
||||||
@ -307,7 +327,10 @@ sub database_dump_compress {
|
|||||||
print `perl db_dumper.pl database="$db" loc="backups" compress`;
|
print `perl db_dumper.pl database="$db" loc="backups" compress`;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub script_exit{ }
|
sub script_exit{
|
||||||
|
#::: Cleanup staged folder...
|
||||||
|
rmtree("updates_staged/");
|
||||||
|
}
|
||||||
|
|
||||||
#::: Returns Tab Delimited MySQL Result from Command Line
|
#::: Returns Tab Delimited MySQL Result from Command Line
|
||||||
sub get_mysql_result{
|
sub get_mysql_result{
|
||||||
@ -357,31 +380,44 @@ sub get_remote_file{
|
|||||||
if($OS eq "Windows"){
|
if($OS eq "Windows"){
|
||||||
#::: For non-text type requests...
|
#::: For non-text type requests...
|
||||||
if($content_type == 1){
|
if($content_type == 1){
|
||||||
|
$break = 0;
|
||||||
|
while($break == 0) {
|
||||||
use LWP::Simple qw(getstore);
|
use LWP::Simple qw(getstore);
|
||||||
if(!getstore($URL, $Dest_File)){
|
if(!getstore($URL, $Dest_File)){
|
||||||
print "Error, no connection or failed request...\n\n";
|
# print "Error, no connection or failed request...\n\n";
|
||||||
}
|
}
|
||||||
else{
|
# sleep(1);
|
||||||
print " o URL: (" . $URL . ")\n";
|
#::: Make sure the file exists before continuing...
|
||||||
print " o Saved: (" . $Dest_File . ") \n";
|
if(-e $Dest_File) {
|
||||||
|
$break = 1;
|
||||||
|
print " [URL] :: " . $URL . "\n";
|
||||||
|
print " [Saved] :: " . $Dest_File . "\n";
|
||||||
|
} else { $break = 0; }
|
||||||
|
usleep(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
$break = 0;
|
||||||
|
while($break == 0) {
|
||||||
require LWP::UserAgent;
|
require LWP::UserAgent;
|
||||||
my $ua = LWP::UserAgent->new;
|
my $ua = LWP::UserAgent->new;
|
||||||
$ua->timeout(10);
|
$ua->timeout(10);
|
||||||
$ua->env_proxy;
|
$ua->env_proxy;
|
||||||
my $response = $ua->get($URL);
|
my $response = $ua->get($URL);
|
||||||
|
|
||||||
if ($response->is_success){
|
if ($response->is_success){
|
||||||
open (FILE, '> ' . $Dest_File . '');
|
open (FILE, '> ' . $Dest_File . '');
|
||||||
print FILE $response->decoded_content;
|
print FILE $response->decoded_content;
|
||||||
close (FILE);
|
close (FILE);
|
||||||
print " o URL: (" . $URL . ")\n";
|
|
||||||
print " o Saved: (" . $Dest_File . ") \n";
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print "Error, no connection or failed request...\n\n";
|
# 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -473,6 +509,53 @@ sub copy_file{
|
|||||||
copy $l_source_file, $l_dest_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{
|
sub map_files_fetch_bulk{
|
||||||
print "\n --- Fetching Latest Maps... (This could take a few minutes...) --- \n";
|
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);
|
get_remote_file("http://github.com/Akkadius/EQEmuMaps/archive/master.zip", "maps/maps.zip", 1);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user