diff --git a/Database/Configuration.cs b/Database/Configuration.cs index bbc2c952..0dc2e6d0 100644 --- a/Database/Configuration.cs +++ b/Database/Configuration.cs @@ -46,6 +46,24 @@ namespace Activizr.Database private static Configuration _configuration; + public static bool TestConfigurationWritable() + { + try + { + using (FileStream stream = new FileStream(GetConfigurationFileName(), FileMode.Append, FileAccess.Write, FileShare.ReadWrite)) + { + // do nothing + } + } + catch (Exception) + { + + return false; + } + + return true; + } + public static void Load() { XmlSerializer serializer = new XmlSerializer(typeof(Configuration)); diff --git a/Site5/Pages/v5/Init/Default.aspx b/Site5/Pages/v5/Init/Default.aspx index 0792079d..23406874 100644 --- a/Site5/Pages/v5/Init/Default.aspx +++ b/Site5/Pages/v5/Init/Default.aspx @@ -8,6 +8,7 @@ + @@ -78,6 +79,29 @@ $('#<%=this.TextServerName.ClientID %>').css('background-image', "none"); $('#<%=this.TextServerAddress.ClientID %>').css('background-image', "none"); } + + if (isValid) { // Validate writability of config file + $.ajax({ + type: "POST", + url: "Default.aspx/IsConfigurationFileWritable", + data: "{}", + contentType: "application/json; charset=utf-8", + dataType: "json", + async: false, // blocks until function returns - race conditions otherwise + success: function (msg) { + if (msg.d == true) { + // Yes, config is writable. Hide "unwritable" div, show "writable" div, all is nice + $('#DivDatabaseUnwritable').css('display', 'none'); + $('#DivDatabaseWritable').css('display', 'inline'); + } else { + // Config is NOT writable. Keep the error on-screen and keep re-checking every two seconds. + + setTimeout('recheckConfigurationWritability();', 5000); // 5s until first re-check + } + } + }); + } + } else if (stepNumber == 2) { isValid = true; // assume true, make false as we go @@ -106,6 +130,28 @@ } return isValid; } + + function recheckConfigurationWritability() { + $.ajax({ + type: "POST", + url: "Default.aspx/IsConfigurationFileWritable", + data: "{}", + contentType: "application/json; charset=utf-8", + dataType: "json", + async: false, // blocks until function returns - race conditions otherwise + success: function (msg) { + if (msg.d == true) { + // Yes, config is writable. Hide "unwritable" div, show "writable" div, all is nice + $('#DivDatabaseUnwritable').slideUp('fast').fadeOut('fast'); + $('#DivDatabaseWritable').fadeIn('fast'); + } else { + // Config is NOT writable. Keep the error on-screen and keep re-checking every two seconds. + + setTimeout('recheckConfigurationWritability();', 2000); // 5s until first re-check + } + } + }); + } }); @@ -304,7 +350,14 @@
-

Connect to database

+
+

Fix File Permissions

+

Before we can proceed, you need to make the configuration file writable. Please open a shell to the Activizr server and execute the following commands:

+

cd /opt/activizr/frontend
sudo chown www-data:www-data database.config
sudo chmod o+w database.config

+

The installation will continue when it detects that these steps have been done.

+
+

Step 3 Content

diff --git a/Site5/Pages/v5/Init/Default.aspx.cs b/Site5/Pages/v5/Init/Default.aspx.cs index e77df914..90f01944 100644 --- a/Site5/Pages/v5/Init/Default.aspx.cs +++ b/Site5/Pages/v5/Init/Default.aspx.cs @@ -320,4 +320,10 @@ public partial class Pages_v5_Init_Default : System.Web.UI.Page { return VerifyHostName(name) && VerifyHostAddress(address); } + + [WebMethod(true)] + public static bool IsConfigurationFileWritable() + { + return PirateDb.Configuration.TestConfigurationWritable(); + } } \ No newline at end of file diff --git a/Site5/Pages/v5/Init/WizardStyle.css b/Site5/Pages/v5/Init/WizardStyle.css index d35c38fd..7a504ce1 100644 --- a/Site5/Pages/v5/Init/WizardStyle.css +++ b/Site5/Pages/v5/Init/WizardStyle.css @@ -53,17 +53,17 @@ position: relative; clear:right; margin: 3px 0 0 0; - border: 1px solid #CCC; + /*border: 1px solid #CCC;*/ padding: 0; color: #5A5655; - background-color: #F8F8F8; + /*background-color: #F8F8F8;*/ height:40px; /* width:730px; float:right; */ text-align:left; overflow:auto; z-index:88; - border-radius: 5px; + /*border-radius: 5px;*/ } .swMain .stepContainer .StepTitle {