diff options
Diffstat (limited to 'OpenSim/Server')
-rw-r--r-- | OpenSim/Server/Base/ServicesServerBase.cs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs index a5bebb8..dee31bd 100644 --- a/OpenSim/Server/Base/ServicesServerBase.cs +++ b/OpenSim/Server/Base/ServicesServerBase.cs | |||
@@ -230,6 +230,12 @@ namespace OpenSim.Server.Base | |||
230 | "shutdown", | 230 | "shutdown", |
231 | "Quit the application", HandleQuit); | 231 | "Quit the application", HandleQuit); |
232 | 232 | ||
233 | // Register a command to read other commands from a file | ||
234 | MainConsole.Instance.Commands.AddCommand("base", false, "command-script", | ||
235 | "command-script <script>", | ||
236 | "Run a command script from file", HandleScript); | ||
237 | |||
238 | |||
233 | // Allow derived classes to perform initialization that | 239 | // Allow derived classes to perform initialization that |
234 | // needs to be done after the console has opened | 240 | // needs to be done after the console has opened |
235 | // | 241 | // |
@@ -259,6 +265,41 @@ namespace OpenSim.Server.Base | |||
259 | m_log.Info("[CONSOLE] Quitting"); | 265 | m_log.Info("[CONSOLE] Quitting"); |
260 | } | 266 | } |
261 | 267 | ||
268 | protected virtual void HandleScript(string module, string[] parms) | ||
269 | { | ||
270 | if (parms.Length != 2) | ||
271 | { | ||
272 | return; | ||
273 | } | ||
274 | RunCommandScript(parms[1]); | ||
275 | } | ||
276 | |||
277 | /// <summary> | ||
278 | /// Run an optional startup list of commands | ||
279 | /// </summary> | ||
280 | /// <param name="fileName"></param> | ||
281 | private void RunCommandScript(string fileName) | ||
282 | { | ||
283 | if (File.Exists(fileName)) | ||
284 | { | ||
285 | m_log.Info("[COMMANDFILE]: Running " + fileName); | ||
286 | |||
287 | using (StreamReader readFile = File.OpenText(fileName)) | ||
288 | { | ||
289 | string currentCommand; | ||
290 | while ((currentCommand = readFile.ReadLine()) != null) | ||
291 | { | ||
292 | if (currentCommand != String.Empty) | ||
293 | { | ||
294 | m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'"); | ||
295 | MainConsole.Instance.RunCommand(currentCommand); | ||
296 | } | ||
297 | } | ||
298 | } | ||
299 | } | ||
300 | } | ||
301 | |||
302 | |||
262 | protected virtual void ReadConfig() | 303 | protected virtual void ReadConfig() |
263 | { | 304 | { |
264 | } | 305 | } |