aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie2009-08-19 04:39:02 +0100
committerMelanie2009-08-19 04:39:02 +0100
commit99c7a43ffdb9c3b4dee984f7cd788742c6ee3e53 (patch)
tree81cbdfaeae6ce37ce16463c602e6cb8b9077f275
parentFixes mantis #4020 (http://opensimulator.org/mantis/view.php?id=4020) (diff)
downloadopensim-SC_OLD-99c7a43ffdb9c3b4dee984f7cd788742c6ee3e53.zip
opensim-SC_OLD-99c7a43ffdb9c3b4dee984f7cd788742c6ee3e53.tar.gz
opensim-SC_OLD-99c7a43ffdb9c3b4dee984f7cd788742c6ee3e53.tar.bz2
opensim-SC_OLD-99c7a43ffdb9c3b4dee984f7cd788742c6ee3e53.tar.xz
Add rest console support to the user server. Will ask new questions at
startup. To use, run it normally once, answering the questions, then run again with -console=rest. Also now supports -console=basic for a console that reads stdin
-rw-r--r--OpenSim/Framework/UserConfig.cs14
-rw-r--r--OpenSim/Grid/UserServer/Main.cs39
-rw-r--r--OpenSim/Server/Base/ServicesServerBase.cs28
-rw-r--r--prebuild.xml1
4 files changed, 81 insertions, 1 deletions
diff --git a/OpenSim/Framework/UserConfig.cs b/OpenSim/Framework/UserConfig.cs
index 31838ad..b9e3665 100644
--- a/OpenSim/Framework/UserConfig.cs
+++ b/OpenSim/Framework/UserConfig.cs
@@ -46,6 +46,8 @@ namespace OpenSim.Framework
46 public bool HttpSSL = ConfigSettings.DefaultUserServerHttpSSL; 46 public bool HttpSSL = ConfigSettings.DefaultUserServerHttpSSL;
47 public uint DefaultUserLevel = 0; 47 public uint DefaultUserLevel = 0;
48 public string LibraryXmlfile = ""; 48 public string LibraryXmlfile = "";
49 public string ConsoleUser = String.Empty;
50 public string ConsolePass = String.Empty;
49 51
50 private Uri m_inventoryUrl; 52 private Uri m_inventoryUrl;
51 53
@@ -155,6 +157,12 @@ namespace OpenSim.Framework
155 m_configMember.addConfigurationOption("default_loginLevel", ConfigurationOption.ConfigurationTypes.TYPE_UINT32, 157 m_configMember.addConfigurationOption("default_loginLevel", ConfigurationOption.ConfigurationTypes.TYPE_UINT32,
156 "Minimum Level a user should have to login [0 default]", "0", false); 158 "Minimum Level a user should have to login [0 default]", "0", false);
157 159
160 m_configMember.addConfigurationOption("console_user", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
161 "Remote console access user name [Default: disabled]", "0", false);
162
163 m_configMember.addConfigurationOption("console_pass", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
164 "Remote console access password [Default: disabled]", "0", false);
165
158 } 166 }
159 167
160 public bool handleIncomingConfiguration(string configuration_key, object configuration_result) 168 public bool handleIncomingConfiguration(string configuration_key, object configuration_result)
@@ -209,6 +217,12 @@ namespace OpenSim.Framework
209 case "library_location": 217 case "library_location":
210 LibraryXmlfile = (string)configuration_result; 218 LibraryXmlfile = (string)configuration_result;
211 break; 219 break;
220 case "console_user":
221 ConsoleUser = (string)configuration_result;
222 break;
223 case "console_pass":
224 ConsolePass = (string)configuration_result;
225 break;
212 } 226 }
213 227
214 return true; 228 return true;
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index 86c2abb..f47a96e 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -43,6 +43,7 @@ using OpenSim.Framework.Statistics;
43using OpenSim.Grid.Communications.OGS1; 43using OpenSim.Grid.Communications.OGS1;
44using OpenSim.Grid.Framework; 44using OpenSim.Grid.Framework;
45using OpenSim.Grid.UserServer.Modules; 45using OpenSim.Grid.UserServer.Modules;
46using Nini.Config;
46 47
47namespace OpenSim.Grid.UserServer 48namespace OpenSim.Grid.UserServer
48{ 49{
@@ -73,8 +74,22 @@ namespace OpenSim.Grid.UserServer
73 74
74 protected AvatarCreationModule m_appearanceModule; 75 protected AvatarCreationModule m_appearanceModule;
75 76
77 protected static string m_consoleType = "local";
78 protected static IConfigSource m_config = null;
79
76 public static void Main(string[] args) 80 public static void Main(string[] args)
77 { 81 {
82 ArgvConfigSource argvSource = new ArgvConfigSource(args);
83 argvSource.AddSwitch("Startup", "console", "c");
84
85 IConfig startupConfig = argvSource.Configs["Startup"];
86 if (startupConfig != null)
87 {
88 m_consoleType = startupConfig.GetString("console", "local");
89 }
90
91 m_config = argvSource;
92
78 XmlConfigurator.Configure(); 93 XmlConfigurator.Configure();
79 94
80 m_log.Info("Launching UserServer..."); 95 m_log.Info("Launching UserServer...");
@@ -87,7 +102,18 @@ namespace OpenSim.Grid.UserServer
87 102
88 public OpenUser_Main() 103 public OpenUser_Main()
89 { 104 {
90 m_console = new LocalConsole("User"); 105 switch (m_consoleType)
106 {
107 case "rest":
108 m_console = new RemoteConsole("User");
109 break;
110 case "basic":
111 m_console = new CommandConsole("User");
112 break;
113 default:
114 m_console = new LocalConsole("User");
115 break;
116 }
91 MainConsole.Instance = m_console; 117 MainConsole.Instance = m_console;
92 } 118 }
93 119
@@ -129,6 +155,17 @@ namespace OpenSim.Grid.UserServer
129 155
130 m_httpServer = new BaseHttpServer(Cfg.HttpPort); 156 m_httpServer = new BaseHttpServer(Cfg.HttpPort);
131 157
158 if (m_console is RemoteConsole)
159 {
160 System.Console.WriteLine("Initialized REST console");
161 RemoteConsole c = (RemoteConsole)m_console;
162 c.SetServer(m_httpServer);
163 IConfig netConfig = m_config.AddConfig("Network");
164 netConfig.Set("ConsoleUser", Cfg.ConsoleUser);
165 netConfig.Set("ConsolePass", Cfg.ConsolePass);
166 c.ReadConfig(m_config);
167 }
168
132 RegisterInterface<CommandConsole>(m_console); 169 RegisterInterface<CommandConsole>(m_console);
133 RegisterInterface<UserConfig>(Cfg); 170 RegisterInterface<UserConfig>(Cfg);
134 171
diff --git a/OpenSim/Server/Base/ServicesServerBase.cs b/OpenSim/Server/Base/ServicesServerBase.cs
index 619c2d1..1d9eb0d 100644
--- a/OpenSim/Server/Base/ServicesServerBase.cs
+++ b/OpenSim/Server/Base/ServicesServerBase.cs
@@ -65,6 +65,10 @@ namespace OpenSim.Server.Base
65 // 65 //
66 private bool m_Running = true; 66 private bool m_Running = true;
67 67
68 // PID file
69 //
70 private string m_pidFile = String.Empty;
71
68 // Handle all the automagical stuff 72 // Handle all the automagical stuff
69 // 73 //
70 public ServicesServerBase(string prompt, string[] args) 74 public ServicesServerBase(string prompt, string[] args)
@@ -211,6 +215,11 @@ namespace OpenSim.Server.Base
211 } 215 }
212 } 216 }
213 217
218 if (startupConfig.GetString("PIDFile", String.Empty) != String.Empty)
219 {
220 CreatePIDFile(startupConfig.GetString("PIDFile"));
221 }
222
214 // Register the quit command 223 // Register the quit command
215 // 224 //
216 MainConsole.Instance.Commands.AddCommand("base", false, "quit", 225 MainConsole.Instance.Commands.AddCommand("base", false, "quit",
@@ -230,6 +239,8 @@ namespace OpenSim.Server.Base
230 MainConsole.Instance.Prompt(); 239 MainConsole.Instance.Prompt();
231 } 240 }
232 241
242 if (m_pidFile != String.Empty)
243 File.Delete(m_pidFile);
233 return 0; 244 return 0;
234 } 245 }
235 246
@@ -246,5 +257,22 @@ namespace OpenSim.Server.Base
246 protected virtual void Initialise() 257 protected virtual void Initialise()
247 { 258 {
248 } 259 }
260
261 protected void CreatePIDFile(string path)
262 {
263 try
264 {
265 string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
266 FileStream fs = File.Create(path);
267 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
268 Byte[] buf = enc.GetBytes(pidstring);
269 fs.Write(buf, 0, buf.Length);
270 fs.Close();
271 m_pidFile = path;
272 }
273 catch (Exception)
274 {
275 }
276 }
249 } 277 }
250} 278}
diff --git a/prebuild.xml b/prebuild.xml
index 5e44169..4f110c4 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -1178,6 +1178,7 @@
1178 <Reference name="OpenMetaverse.StructuredData.dll"/> 1178 <Reference name="OpenMetaverse.StructuredData.dll"/>
1179 <Reference name="XMLRPC.dll"/> 1179 <Reference name="XMLRPC.dll"/>
1180 <Reference name="log4net.dll"/> 1180 <Reference name="log4net.dll"/>
1181 <Reference name="Nini.dll"/>
1181 <Reference name="DotNetOpenId.dll"/> 1182 <Reference name="DotNetOpenId.dll"/>
1182 1183
1183 <Files> 1184 <Files>