[simias-svn] SF.net SVN: simias:[7320] branches/iFolder_3.8.0_updates/src
Brought to you by:
srinidhi_bs
|
From: <he...@us...> - 2010-02-28 06:24:42
|
Revision: 7320
http://simias.svn.sourceforge.net/simias/?rev=7320&view=rev
Author: hegdegg
Date: 2010-02-28 06:24:36 +0000 (Sun, 28 Feb 2010)
Log Message:
-----------
When the ip address is changed from web console, apart from saving it in
the config file its also updated into simias.
Modified Paths:
--------------
branches/iFolder_3.8.0_updates/src/server/setup/iFolderWebSetup.cs
branches/iFolder_3.8.0_updates/src/webservices/iFolderServer.cs
Modified: branches/iFolder_3.8.0_updates/src/server/setup/iFolderWebSetup.cs
===================================================================
--- branches/iFolder_3.8.0_updates/src/server/setup/iFolderWebSetup.cs 2010-02-28 05:28:55 UTC (rev 7319)
+++ branches/iFolder_3.8.0_updates/src/server/setup/iFolderWebSetup.cs 2010-02-28 06:24:36 UTC (rev 7320)
@@ -135,10 +135,30 @@
SetupModMono();
#endif
SetupSsl();
-
+
+ UpdateOwnership();
// CheckConnection();
}
+ /// <summary>
+ /// Change the ownership of web.config to apache user so that iFolder
+ /// server can chnage the values while running.
+ /// </summary>
+ void UpdateOwnership()
+ {
+ string MachineArch = Environment.GetEnvironmentVariable("OS_TYPE");
+ string webpath = (MachineArch.IndexOf("_64") > 0) ? Path.GetFullPath("../lib64/simias/web"): Path.GetFullPath("../lib/simiasweb");
+ string webconfigfile = Path.Combine(webpath, "web.config");
+ if (Execute("chown", "{0}:{1} {2}", apacheUser.Value, apacheGroup.Value, webconfigfile) != 0)
+ {
+ throw new Exception("Unable to set an owner for the log path.");
+ }
+ }
+
+ /// <summary>
+ /// Initialize web-access setup
+ /// </summary>
+
/// <summary>
/// Initialize web-access setup
/// </summary>
Modified: branches/iFolder_3.8.0_updates/src/webservices/iFolderServer.cs
===================================================================
--- branches/iFolder_3.8.0_updates/src/webservices/iFolderServer.cs 2010-02-28 05:28:55 UTC (rev 7319)
+++ branches/iFolder_3.8.0_updates/src/webservices/iFolderServer.cs 2010-02-28 06:24:36 UTC (rev 7320)
@@ -586,7 +586,7 @@
bool UpdateStatus = false;
string ServerSection="Server";
string PublicAddressKey = "PublicAddress";
- string PrivateAddressKey = "PrivateAddress";
+ string PrivateAddressKey = "PrivateAddress";
string MasterAddressKey = "MasterAddress";
if (!privateUrl.ToLower().StartsWith(Uri.UriSchemeHttp))
{
@@ -596,12 +596,15 @@
{
publicUrl = (new UriBuilder(Uri.UriSchemeHttp, publicUrl)).ToString();
}
+ if (MasterUrl != null && !privateUrl.ToLower().StartsWith(Uri.UriSchemeHttp))
+ {
+ MasterUrl = (new UriBuilder(Uri.UriSchemeHttp, MasterUrl)).ToString();
+ }
// adding /simias10
privateUrl = AddVirtualPath( privateUrl );
publicUrl = AddVirtualPath( publicUrl );
-
-
+
string SimiasConfigFilePath = Path.Combine ( Store.StorePath, "Simias.config");
if ( File.Exists( Path.Combine( Store.StorePath, Simias.Configuration.DefaultConfigFileName ) ) == true )
{
@@ -618,6 +621,7 @@
XmlDocument document = new XmlDocument();
document.Load(SimiasConfigFilePath );
+
SetConfigValue( document, ServerSection, PublicAddressKey, publicUrl );
SetConfigValue( document, ServerSection, PrivateAddressKey, privateUrl );
if(MasterUrl != "")
@@ -626,6 +630,12 @@
UpdateStatus = SetConfigValueWithSSL( document, ServerSection, MasterAddressKey, MasterUrl );
if(UpdateStatus == false)
return false;
+ if (MasterUrl != null)
+ {
+ UpdateStatus = UpdateMasterURL(MasterUrl);
+ if(UpdateStatus == false)
+ return false;
+ }
}
// Commit the config file changes.
@@ -636,8 +646,52 @@
{
SmartException.Throw(ex);
}
+ // Also update in the simias.
+ SetOnMasterUpdateUri(RemoveVirtualPath(privateUrl), RemoveVirtualPath(publicUrl));
+
return UpdateStatus;
}
+ /// <summary>
+ /// Update the Master Url in the local store
+ /// </summary>
+ /// <param name="masterUrl">
+ /// A <see cref="System.String"/>
+ /// </param>
+ /// /// <returns>
+ /// A <see cref="System.Boolean"/>
+ /// </returns>
+ private static bool UpdateMasterURL( string masterUrl)
+ {
+ bool retVal = true;;
+ try
+ {
+ Store store = Store.GetStore();
+ Domain domain = store.GetDomain(store.DefaultDomain);
+ HostNode masterNode = HostNode.GetMaster(domain.ID);
+ masterNode.PrivateUrl = masterUrl;
+ domain.Commit(masterNode);
+ }
+ catch (Exception ex)
+ {
+ log.Debug("Exception in UpdateMasterURL" + ex.Message);
+ retVal = false;
+ }
+ return retVal;
+ }
+ /// <summary>
+ /// Adds simias10 into the path
+ /// </summary>
+ /// <param name="path"></param>
+ /// <returns>new path</returns>
+ private static string RemoveVirtualPath(string path)
+ {
+ path = path.TrimEnd('/');
+ if(path.EndsWith("/simias10") == true)
+ {
+ path = path.Substring(0, path.IndexOf("simias10"));
+ }
+ return path;
+ }
/// <summary>
/// Adds simias10 into the path
@@ -746,7 +800,8 @@
{
if (masterAddress.ToLower().StartsWith(Uri.UriSchemeHttps))
{
- string webPath = Path.GetFullPath("../../../../lib/simias/web");
+ string machineArch = Environment.GetEnvironmentVariable("OS_TYPE");
+ string webPath = ( machineArch.IndexOf("_64" ) > 0 ? Path.GetFullPath("../../../../lib64/simias/web"): Path.GetFullPath("../../../../lib/simias/web"));
// swap policy
ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|