mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 18:51:29 +00:00
Config XML to JSON conversion routines
This commit is contained in:
parent
dad6f2ead5
commit
ec6b74aa7f
@ -472,16 +472,6 @@ bool Database::CheckDatabaseConversions() {
|
|||||||
CheckDatabaseConvertPPDeblob();
|
CheckDatabaseConvertPPDeblob();
|
||||||
CheckDatabaseConvertCorpseDeblob();
|
CheckDatabaseConvertCorpseDeblob();
|
||||||
|
|
||||||
/* Fetch EQEmu Server script */
|
|
||||||
if (!std::ifstream("eqemu_server.pl")){
|
|
||||||
std::cout << "Pulling down automatic database upgrade script..." << std::endl;
|
|
||||||
#ifdef _WIN32
|
|
||||||
system("perl -MLWP::UserAgent -e \"require LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; my $response = $ua->get('https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/eqemu_server.pl'); if ($response->is_success){ open(FILE, '> eqemu_server.pl'); print FILE $response->decoded_content; close(FILE); }\"");
|
|
||||||
#else
|
|
||||||
system("wget --no-check-certificate -O eqemu_server.pl https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/eqemu_server.pl");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Run EQEmu Server script (Checks for database updates) */
|
/* Run EQEmu Server script (Checks for database updates) */
|
||||||
system("perl eqemu_server.pl ran_from_world");
|
system("perl eqemu_server.pl ran_from_world");
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@ use File::Copy qw(copy);
|
|||||||
use POSIX qw(strftime);
|
use POSIX qw(strftime);
|
||||||
use File::Path;
|
use File::Path;
|
||||||
use File::Find;
|
use File::Find;
|
||||||
use Time::HiRes qw(usleep);
|
use Time::HiRes qw(usleep);
|
||||||
|
|
||||||
#::: Variables
|
#::: Variables
|
||||||
$install_repository_request_url = "https://raw.githubusercontent.com/Akkadius/EQEmuInstall/master/";
|
$install_repository_request_url = "https://raw.githubusercontent.com/Akkadius/EQEmuInstall/master/";
|
||||||
@ -49,6 +49,7 @@ if(-e "eqemu_server_skip_update.txt"){
|
|||||||
|
|
||||||
#::: Check for script self update
|
#::: Check for script self update
|
||||||
do_self_update_check_routine() if !$skip_self_update_check;
|
do_self_update_check_routine() if !$skip_self_update_check;
|
||||||
|
check_xml_to_json_conversion() if $ARGV[0] eq "convert_xml";
|
||||||
get_windows_wget();
|
get_windows_wget();
|
||||||
get_perl_version();
|
get_perl_version();
|
||||||
read_eqemu_config_xml();
|
read_eqemu_config_xml();
|
||||||
@ -291,6 +292,45 @@ sub new_server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub check_xml_to_json_conversion {
|
||||||
|
if(-e "eqemu_config.xml" && !-e "eqemu_config.json") {
|
||||||
|
|
||||||
|
if($OS eq "Windows"){
|
||||||
|
get_remote_file("https://github.com/EQEmu/Server/blob/eqemu_config_json/utils/xmltojson/xmltojson-windows-x86.exe", "xmltojson.exe");
|
||||||
|
print "Converting eqemu_config.xml to eqemu_config.json\n";
|
||||||
|
print `xmltojson eqemu_config.xml`;
|
||||||
|
}
|
||||||
|
if($OS eq "Linux"){
|
||||||
|
get_remote_file("https://github.com/EQEmu/Server/blob/eqemu_config_json/utils/xmltojson/xmltojson-linux-x86", "xmltojson");
|
||||||
|
print "Converting eqemu_config.xml to eqemu_config.json\n";
|
||||||
|
print `xmltojson eqemu_config.xml`;
|
||||||
|
}
|
||||||
|
|
||||||
|
#::: Prettify and alpha order the config
|
||||||
|
use JSON;
|
||||||
|
my $json = new JSON();
|
||||||
|
|
||||||
|
my $content;
|
||||||
|
open(my $fh, '<', "eqemu_config.json") or die "cannot open file $filename"; {
|
||||||
|
local $/;
|
||||||
|
$content = <$fh>;
|
||||||
|
}
|
||||||
|
close($fh);
|
||||||
|
|
||||||
|
$result = $json->decode($content);
|
||||||
|
$json->canonical(1);
|
||||||
|
|
||||||
|
print $json->pretty->utf8->encode($result),"\n";
|
||||||
|
|
||||||
|
open(my $fh, '>', 'eqemu_config.json');
|
||||||
|
print $fh $json->pretty->utf8->encode($result);
|
||||||
|
close $fh;
|
||||||
|
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
sub build_linux_source {
|
sub build_linux_source {
|
||||||
|
|
||||||
$build_options = $_[0];
|
$build_options = $_[0];
|
||||||
|
|||||||
@ -103,12 +103,23 @@ EQEmuLogSys LogSys;
|
|||||||
WebInterfaceList web_interface;
|
WebInterfaceList web_interface;
|
||||||
|
|
||||||
void CatchSignal(int sig_num);
|
void CatchSignal(int sig_num);
|
||||||
|
void CheckForServerScript(bool force_download = false);
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
RegisterExecutablePlatform(ExePlatformWorld);
|
RegisterExecutablePlatform(ExePlatformWorld);
|
||||||
LogSys.LoadLogSettingsDefaults();
|
LogSys.LoadLogSettingsDefaults();
|
||||||
set_exception_handler();
|
set_exception_handler();
|
||||||
|
|
||||||
|
/* Download EQEmu Server Maintenance Script if doesn't exist */
|
||||||
|
CheckForServerScript();
|
||||||
|
|
||||||
|
/* If eqemu_config.json does not exist - create it from conversion... */
|
||||||
|
if (!std::ifstream("eqemu_config.json")) {
|
||||||
|
CheckForServerScript(true);
|
||||||
|
/* Run EQEmu Server script (Checks for database updates) */
|
||||||
|
system("perl eqemu_server.pl convert_xml");
|
||||||
|
}
|
||||||
|
|
||||||
/* Database Version Check */
|
/* Database Version Check */
|
||||||
uint32 Database_Version = CURRENT_BINARY_DATABASE_VERSION;
|
uint32 Database_Version = CURRENT_BINARY_DATABASE_VERSION;
|
||||||
uint32 Bots_Database_Version = CURRENT_BINARY_BOTS_DATABASE_VERSION;
|
uint32 Bots_Database_Version = CURRENT_BINARY_BOTS_DATABASE_VERSION;
|
||||||
@ -577,3 +588,15 @@ void UpdateWindowTitle(char* iNewTitle) {
|
|||||||
SetConsoleTitle(tmp);
|
SetConsoleTitle(tmp);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CheckForServerScript(bool force_download) {
|
||||||
|
/* Fetch EQEmu Server script */
|
||||||
|
if (!std::ifstream("eqemu_server.pl") || force_download) {
|
||||||
|
std::cout << "Pulling down EQEmu Server Maintenance Script (eqemu_server.pl)..." << std::endl;
|
||||||
|
#ifdef _WIN32
|
||||||
|
system("perl -MLWP::UserAgent -e \"require LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->env_proxy; my $response = $ua->get('https://raw.githubusercontent.com/EQEmu/Server/eqemu_config_json/utils/scripts/eqemu_server.pl'); if ($response->is_success){ open(FILE, '> eqemu_server.pl'); print FILE $response->decoded_content; close(FILE); }\"");
|
||||||
|
#else
|
||||||
|
system("wget --no-check-certificate -O eqemu_server.pl https://raw.githubusercontent.com/EQEmu/Server/eqemu_config_json/utils/scripts/eqemu_server.pl");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user