diff options
Small bit of refactoring to the startup command script code (moved it into a separate method), so that I could add a new CLI command of "command-script <fileName>", so that as well as the startup command script still being processed on startup. A user can create other command scripts and use the single command ("command-script <filename>") to run them at any time. Could be useful for trying out various configurations etc.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Application/OpenSimMain.cs | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs index 867f16f..07ab34d 100644 --- a/OpenSim/Region/Application/OpenSimMain.cs +++ b/OpenSim/Region/Application/OpenSimMain.cs | |||
@@ -205,28 +205,33 @@ namespace OpenSim | |||
205 | //Run Startup Commands | 205 | //Run Startup Commands |
206 | if (m_startupCommandsFile != "") | 206 | if (m_startupCommandsFile != "") |
207 | { | 207 | { |
208 | MainLog.Instance.Verbose("Running startup command script (" + m_startupCommandsFile + ")"); | 208 | RunCommandScript(m_startupCommandsFile); |
209 | if (File.Exists(m_startupCommandsFile)) | 209 | } |
210 | else | ||
211 | { | ||
212 | MainLog.Instance.Verbose("No startup command script specified. Moving on..."); | ||
213 | } | ||
214 | } | ||
215 | |||
216 | private void RunCommandScript(string fileName) | ||
217 | { | ||
218 | MainLog.Instance.Verbose("Running command script (" + fileName + ")"); | ||
219 | if (File.Exists(fileName)) | ||
220 | { | ||
221 | StreamReader readFile = File.OpenText(fileName); | ||
222 | string currentCommand = ""; | ||
223 | while ((currentCommand = readFile.ReadLine()) != null) | ||
210 | { | 224 | { |
211 | StreamReader readFile = File.OpenText(m_startupCommandsFile); | 225 | if (currentCommand != "") |
212 | string currentCommand = ""; | ||
213 | while ((currentCommand = readFile.ReadLine()) != null) | ||
214 | { | 226 | { |
215 | if (currentCommand != "") | 227 | MainLog.Instance.Verbose("Running '" + currentCommand + "'"); |
216 | { | 228 | MainLog.Instance.MainLogRunCommand(currentCommand); |
217 | MainLog.Instance.Verbose("Running '" + currentCommand + "'"); | ||
218 | MainLog.Instance.MainLogRunCommand(currentCommand); | ||
219 | } | ||
220 | } | 229 | } |
221 | } | 230 | } |
222 | else | ||
223 | { | ||
224 | MainLog.Instance.Error("Startup command script missing. Will not run startup commands"); | ||
225 | } | ||
226 | } | 231 | } |
227 | else | 232 | else |
228 | { | 233 | { |
229 | MainLog.Instance.Verbose("No startup command script specified. Moving on..."); | 234 | MainLog.Instance.Error("Command script missing. Can not run commands"); |
230 | } | 235 | } |
231 | } | 236 | } |
232 | 237 | ||
@@ -403,6 +408,13 @@ namespace OpenSim | |||
403 | } | 408 | } |
404 | break; | 409 | break; |
405 | 410 | ||
411 | case "command-script": | ||
412 | if (cmdparams.Length > 0) | ||
413 | { | ||
414 | RunCommandScript(cmdparams[0]); | ||
415 | } | ||
416 | break; | ||
417 | |||
406 | case "permissions": | 418 | case "permissions": |
407 | // Treats each user as a super-admin when disabled | 419 | // Treats each user as a super-admin when disabled |
408 | foreach (Scene scene in m_localScenes) | 420 | foreach (Scene scene in m_localScenes) |