dsrc isn't necessary for this repo
[client-tools.git] / exe / shared / createDefaultConfig.pl
blobe971e2783ea01a657d73d3ee57b7d439c9e4c39c
1 use FindBin '$Bin';
2 use Sys::Hostname;
3 use Getopt::Long;
4 use Socket;
6 &GetOptions("clustername:s", "dbuser:s", "host:s", "dbservice:s", "help");
7 if($::opt_help)
9 print "Usage: $0 [OPTION]...\n";
10 print "Options:\n";
11 print " --clustername=<clustername> create default.cfg using <clustername> as the cluster name\n";
12 print " --dbuser=<db user id> use <db user id> to id the server\n";
13 print " --host:<hostname> create a default.cfg that uses <hostname> for server addresses\n";
14 print " --dbservice:<db server> use <db server> (e.g. from tnsnames)\n";
15 print "\nBy default, the script will try to generate a default.cfg using reasonable defaults.\n";
18 # get hostname
19 my $hostname = hostname();
20 if($::opt_host)
22 $hostname=$::opt_host;
25 my $dbuser = getpwuid($<);
27 if($::opt_dbuser)
29 $dbuser = $::opt_dbuser;
31 else
33 my $branch = "";
34 @dirs = split('/', $Bin);
35 $x = 0;
36 for $i(@dirs)
38 if($i eq "swg")
40 $branch = @dirs[$x+1];
41 break;
43 $x++;
46 $dbuser = "$dbuser\_$branch";
49 my $dbservice="swodb";
50 if($::opt_dbservice)
52 $dbservice = $::opt_dbservice;
55 my $clustername = getpwuid($<);
56 if($::opt_clustername)
58 $clustername = $::opt_clustername;
62 my $hostip = inet_ntoa(inet_aton($hostname));
64 open (CONFIG, "> default.cfg") or die "Could not open default.cfg for writing\n";
65 print CONFIG "[TaskManager]\n";
66 print CONFIG "loginServerAddress=aus-lindevlogin-01.starwarsgalaxies.net\n";
67 print CONFIG "clusterName=$clustername\n";
68 print CONFIG "node0=$hostip\n\n";
69 print CONFIG "[dbProcess]\n";
70 print CONFIG "DSN=$dbservice\n";
71 print CONFIG "databaseUID=$dbuser\n\n";
72 print CONFIG "[LoginServer]\n";
73 print CONFIG "DSN=$dbservice\n";
74 print CONFIG "databaseUID=$dbuser\n";
75 print CONFIG "developmentMode=true\n";
76 print CONFIG "\n[CentralServer]\n";
77 print CONFIG "developmentMode=true\n";
78 print CONFIG "\n[GameServer]\n";
79 print CONFIG "adminGodToAll=true\n";
81 close(CONFIG);
83 if(! open(TMRC, "<taskmanager.rc"))
85 open(TMRC, ">taskmanager.rc") or die "could not open taskmanager.rc for writing\n";
86 print TMRC "CentralServer local debug/CentralServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
87 print TMRC "ConnectionServer local debug/ConnectionServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
88 print TMRC "SwgDatabaseServer local debug/SwgDatabaseServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
89 print TMRC "PlanetServer local debug/PlanetServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
90 print TMRC "SwgGameServer any debug/SwgGameServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
91 print TMRC "ChatServer local debug/ChatServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
92 print TMRC "LogServer local debug/LogServer -- \@serverNetwork.cfg \@logServerTargets.cfg\n";
93 print TMRC "MetricsServer local debug/MetricsServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
94 print TMRC "CommoditiesServer local debug/CommoditiesServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
95 close(TMRC);
98 if(! open(TMRC, "<taskmanager.debug.rc"))
100 open(TMRC, ">taskmanager.debug.rc") or die "could not open taskmanager.debug.rc for writing\n";
101 print TMRC "CentralServer local debug/CentralServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
102 print TMRC "ConnectionServer local debug/ConnectionServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
103 print TMRC "SwgDatabaseServer local debug/SwgDatabaseServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
104 print TMRC "PlanetServer local debug/PlanetServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
105 print TMRC "SwgGameServer any debug/SwgGameServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
106 print TMRC "ChatServer local debug/ChatServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
107 print TMRC "LogServer local debug/LogServer -- \@serverNetwork.cfg \@logServerTargets.cfg\n";
108 print TMRC "MetricsServer local debug/MetricsServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
109 print TMRC "CommoditiesServer local debug/CommoditiesServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
110 close(TMRC);
113 if(! open(TMRC, "<taskmanager.release.rc"))
115 open(TMRC, ">taskmanager.release.rc") or die "could not open taskmanager.release.rc for writing\n";
116 print TMRC "CentralServer local release/CentralServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
117 print TMRC "ConnectionServer local release/ConnectionServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
118 print TMRC "SwgDatabaseServer local release/SwgDatabaseServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
119 print TMRC "PlanetServer local release/PlanetServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
120 print TMRC "SwgGameServer any release/SwgGameServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
121 print TMRC "ChatServer local release/ChatServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
122 print TMRC "LogServer local release/LogServer -- \@serverNetwork.cfg \@logServerTargets.cfg\n";
123 print TMRC "MetricsServer local release/MetricsServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
124 print TMRC "CommoditiesServer local release/CommoditiesServer -- \@serverNetwork.cfg \@servercommon.cfg\n";
125 close(TMRC);