Added ability to customize db, user suffixes on Init

This commit is contained in:
Rick Falkvinge
2015-06-04 12:01:47 +02:00
parent 95495a1db6
commit 5f4741d3e5
2 changed files with 12 additions and 4 deletions
+3 -2
View File
@@ -193,6 +193,7 @@
if (autoConfigMode) {
jsonData.mysqlHostName = $('#TextMysqlServerHost').val();
jsonData.rootPassword = $('#TextMysqlRootPassword').val();
jsonData.random = $('#<%= this.TextRandomDbLabel.ClientID%>').val();
$.ajax({
type: "POST",
@@ -632,8 +633,8 @@
<h2>Create the database and users</h2>
<p>The Swarmops install sequence can set up the database and users for you, if you provide a root password to the MySQL database server.</p>
<p>(If you don't trust the Swarmops install to do that, that's fine, go to <a href="javascript:goManualCredentials();">manual account credentials</a>.)</p>
<div class="entryLabelsAdmin" style="width:250px">Hostname of MySQL database server<br/>Root password for that MySQL server<br/>&nbsp;</div>
<div class="entryFieldsAdmin"><input type="text" id="TextMysqlServerHost" value="localhost"/>&nbsp;<br/><input type="password" id="TextMysqlRootPassword"/>&nbsp;</div>
<div class="entryLabelsAdmin" style="width:250px">Hostname of MySQL database server<br/>Root password for that MySQL server<br/>Random label (suffixed to db, user names)<br/>&nbsp;</div>
<div class="entryFieldsAdmin"><input type="text" id="TextMysqlServerHost" value="localhost"/>&nbsp;<br/><input type="password" id="TextMysqlRootPassword"/>&nbsp;<br/><asp:TextBox runat="server" ID="TextRandomDbLabel" />&nbsp;</div>
</div>
<div id="DivDatabaseManualConfig" style="display:none">
<h2>Connect to existing database</h2>
+9 -2
View File
@@ -66,6 +66,8 @@ namespace Swarmops.Frontend.Pages.v5.Public
// this.LanguageSelector.LanguageChanged += new EventHandler(LanguageSelector_LanguageChanged);
this.TextRandomDbLabel.Text = Authentication.CreateRandomPassword(5);
Localize();
}
@@ -95,7 +97,7 @@ namespace Swarmops.Frontend.Pages.v5.Public
[WebMethod]
public static bool CreateDatabaseFromRoot (string mysqlHostName, string rootPassword, string serverName,
string ipAddress)
string ipAddress, string random)
{
if (!(VerifyHostName (serverName) && VerifyHostAddress (ipAddress)))
{
@@ -107,7 +109,12 @@ namespace Swarmops.Frontend.Pages.v5.Public
try
{
string random = Authentication.CreateRandomPassword (5);
random = random.Trim();
if (string.IsNullOrEmpty (random))
{
random = Authentication.CreateRandomPassword (5);
}
SwarmDb.Credentials rootCredentials = new SwarmDb.Credentials ("mysql",
new SwarmDb.ServerSet (mysqlHostName), "root", rootPassword);