diff options
Diffstat (limited to 'OpenGridServices/ServiceManager/ServiceManager.cs')
-rw-r--r-- | OpenGridServices/ServiceManager/ServiceManager.cs | 76 |
1 files changed, 71 insertions, 5 deletions
diff --git a/OpenGridServices/ServiceManager/ServiceManager.cs b/OpenGridServices/ServiceManager/ServiceManager.cs index b21a5b1..2491f39 100644 --- a/OpenGridServices/ServiceManager/ServiceManager.cs +++ b/OpenGridServices/ServiceManager/ServiceManager.cs | |||
@@ -4,10 +4,17 @@ using System.Threading; | |||
4 | using System.ServiceProcess; | 4 | using System.ServiceProcess; |
5 | using System.Xml; | 5 | using System.Xml; |
6 | using System.IO; | 6 | using System.IO; |
7 | using libsecondlife; | ||
7 | 8 | ||
8 | public class OpenGridMasterService : System.ServiceProcess.ServiceBase { | 9 | public class OpenGridMasterService : System.ServiceProcess.ServiceBase { |
9 | 10 | ||
10 | private Thread ServiceWorkerThread; | 11 | private Thread ServiceWorkerThread; |
12 | private static string GridURL; | ||
13 | private static string SimSendKey; | ||
14 | private static string SimRecvKey; | ||
15 | private static string AssetURL; | ||
16 | private static string UserSendKey; | ||
17 | private static string UserRecvKey; | ||
11 | 18 | ||
12 | public OpenGridMasterService() | 19 | public OpenGridMasterService() |
13 | { | 20 | { |
@@ -66,13 +73,25 @@ public class OpenGridMasterService : System.ServiceProcess.ServiceBase { | |||
66 | private static string SetupGrid() | 73 | private static string SetupGrid() |
67 | { | 74 | { |
68 | Console.WriteLine("Running external program (OpenGridServices.GridServer.exe) to configure the grid server"); | 75 | Console.WriteLine("Running external program (OpenGridServices.GridServer.exe) to configure the grid server"); |
69 | Process p = new Process(); | 76 | try { |
77 | Process p = new Process(); | ||
70 | 78 | ||
71 | p.StartInfo.Arguments = "-setuponly"; | 79 | p.StartInfo.Arguments = "-setuponly"; |
72 | p.StartInfo.FileName = "OpenGridServices.GridServer.exe"; | 80 | p.StartInfo.FileName = "OpenGridServices.GridServer.exe"; |
73 | p.Start(); | 81 | p.Start(); |
74 | 82 | ||
75 | return "<gridserver />"; // we let the gridserver handle it's own setup | 83 | p.StartInfo.Arguments = "-dumpxmlconf"; |
84 | p.Start(); | ||
85 | |||
86 | StreamReader reader=new StreamReader("opengrid-cfgdump.xml"); | ||
87 | string configxml = reader.ReadToEnd(); | ||
88 | return configxml; | ||
89 | } catch(Exception e) { | ||
90 | Console.WriteLine("An error occurred while running the grid server, please rectify it and try again"); | ||
91 | Console.WriteLine(e.ToString()); | ||
92 | Environment.Exit(1); | ||
93 | } | ||
94 | return ""; | ||
76 | } | 95 | } |
77 | 96 | ||
78 | private static string SetupUser() | 97 | private static string SetupUser() |
@@ -87,6 +106,53 @@ public class OpenGridMasterService : System.ServiceProcess.ServiceBase { | |||
87 | 106 | ||
88 | private static string SetupRegion() | 107 | private static string SetupRegion() |
89 | { | 108 | { |
109 | string regionname; | ||
110 | ulong regionlocx; | ||
111 | ulong regionlocy; | ||
112 | string default_terrain; | ||
113 | uint terrain_multiplier; | ||
114 | uint baseport; | ||
115 | |||
116 | string listenaddr; | ||
117 | string simconfigxml; | ||
118 | LLUUID SimUUID; | ||
119 | |||
120 | Console.WriteLine("Setting up region servers"); | ||
121 | Console.Write("Please specify a path to store your region data (e.g /etc/opensim/regions: "); | ||
122 | string regionpath=Console.ReadLine(); | ||
123 | |||
124 | Console.Write("How many regions would you like to configure now? "); | ||
125 | int numofregions=Convert.ToInt16(Console.ReadLine()); | ||
126 | |||
127 | Console.Write("What port should the region servers start listening at (first region is normally 9000, then 9001 the second etc, both TCP+UDP): "); | ||
128 | baseport=Convert.ToUInt16(Console.ReadLine()); | ||
129 | |||
130 | |||
131 | listenaddr=Console.ReadLine(); | ||
132 | |||
133 | Console.WriteLine("Now ready to configure regions, please answer the questions about each region in turn"); | ||
134 | for(int i=0; i<=numofregions; i++) { | ||
135 | Console.WriteLine("Configuring region number " + i.ToString()); | ||
136 | |||
137 | Console.Write("Region name: "); | ||
138 | regionname=Console.ReadLine(); | ||
139 | |||
140 | Console.Write("Region location X: "); | ||
141 | regionlocx=(ulong)Convert.ToUInt32(Console.ReadLine()); | ||
142 | |||
143 | Console.Write("Region location Y: "); | ||
144 | regionlocy=(ulong)Convert.ToUInt32(Console.ReadLine()); | ||
145 | |||
146 | Console.Write("Default terrain file: "); | ||
147 | default_terrain=Console.ReadLine(); | ||
148 | terrain_multiplier=Convert.ToUInt16(Console.ReadLine()); | ||
149 | |||
150 | SimUUID=LLUUID.Random(); | ||
151 | |||
152 | simconfigxml="<Root><Config SimUUID=\"" + SimUUID.ToString() + "\" SimName=\"" + regionname + "\" SimLocationX=\"" + regionlocx.ToString() + "\" SimLocationY=\"" + regionlocy.ToString() + "\" Datastore=\"" + Path.Combine(regionpath,(SimUUID.ToString()+"localworld.yap")) + "\" SimListenPort=\"" + (baseport+i).ToString() + "\" SimListenAddress=\"" + listenaddr + "\" TerrainFile=\"" + default_terrain + "\" TerrainMultiplier=\"" + terrain_multiplier.ToString() + "\" GridServerURL=\"\" GridSendKey=\"\" GridRecvKey=\"\" AssetServerURL=\"\" /></Root>"; | ||
153 | |||
154 | } | ||
155 | |||
90 | return "<regions></regions>"; | 156 | return "<regions></regions>"; |
91 | } | 157 | } |
92 | 158 | ||