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 @@
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.
+