aboutsummaryrefslogtreecommitdiff
path: root/util/tools/db_load_applets.pl
diff options
context:
space:
mode:
authorDarkelarious <darkelarious@333networks.com>2017-05-13 14:18:28 +0200
committerDarkelarious <darkelarious@333networks.com>2017-05-13 14:20:49 +0200
commit34a2c7390ea9662d33258d384e72fff1912343ff (patch)
treed96ea33c0107e4906a152aa1de4b5c75b81ba0a8 /util/tools/db_load_applets.pl
parent84af66aba26d2088d5d95c240d176f3edaf17b58 (diff)
downloadMasterServer-Perl-34a2c7390ea9662d33258d384e72fff1912343ff.tar.gz
MasterServer-Perl-34a2c7390ea9662d33258d384e72fff1912343ff.zip
revised synchronization methods, config settings and bug fixesv2.3.0
Diffstat (limited to 'util/tools/db_load_applets.pl')
-rwxr-xr-xutil/tools/db_load_applets.pl66
1 files changed, 66 insertions, 0 deletions
diff --git a/util/tools/db_load_applets.pl b/util/tools/db_load_applets.pl
new file mode 100755
index 0000000..9707231
--- /dev/null
+++ b/util/tools/db_load_applets.pl
@@ -0,0 +1,66 @@
+#!/usr/bin/perl
+
+################################################################################
+## Load configuration variables to the database
+##
+## Normally the masterserver loads a number of masterserver applets via the
+## configuration file. This tool allows to load a number of masterserver applets
+## directly into the database without restarting the masterserver.
+##
+## It is generally not necessary to run this script at all. Normally, the
+## masterserver performs the same action on startup.
+##
+## Use with care!
+##
+## Note: set database name / user / password manually in the r_database.pl file!
+################################################################################
+
+use strict;
+use warnings;
+use DBI;
+
+require "r_database.pl";
+require "r_functions.pl";
+
+# open db
+our $dbh;
+
+my @data = (
+ {address => "utmaster.epicgames.com", port => 28900, games => [qw|ut unreal|]},
+ {address => "master.hypercoop.tk", port => 28900, games => [qw|unreal|]},
+ {address => "sof1master.megalag.org", port => 28900, games => [qw|sofretail|]},
+ {address => "master.deusexnetwork.com", port => 28900, games => [qw|deusex|]},
+);
+
+# iterate through all entries
+for my $ms (@data) {
+
+ # iterate through all games per entry
+ for my $g (@{$ms->{games}}) {
+
+ # resolve domain names
+ my $applet_ip = host2ip($ms->{address});
+
+ # check if all credentials are valid
+ if ($applet_ip &&
+ $ms->{port} &&
+ $g)
+ {
+ # add to database
+ add_master_applet(
+ ip => $applet_ip,
+ port => $ms->{port},
+ gamename => $g,
+ );
+ } # else: insufficient info available
+ else {
+ print "fail: could not add master applet: ".
+ ($applet_ip || "ip") .", ".
+ ($ms->{port} || "0") .", ".
+ ($g || "game").".";
+ }
+ }
+}
+
+# close db
+$dbh->disconnect();