public override void Install(IDictionary stateSaver) { base.Install(stateSaver); string targetDir = Context.Parameters[Argument.TargetDir].TrimEnd('\\'); string configFile = Path.Combine(targetDir, Assembly.GetExecutingAssembly().Location + ".config"); System.Configuration.ConfigurationFileMap fileMap = new ConfigurationFileMap(configFile); System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenMappedMachineConfiguration(fileMap); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(delegate(object sender, ResolveEventArgs args) { return(Assembly.LoadFile(Path.Combine(targetDir, args.Name + ".dll"))); }); UhuruSection section = (UhuruSection)config.GetSection("uhuru"); if (!string.IsNullOrEmpty(Context.Parameters[Argument.Capacity])) { section.Service.Capacity = int.Parse(Context.Parameters[Argument.Capacity], CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(Context.Parameters[Argument.BaseDir])) { section.Service.BaseDir = Context.Parameters[Argument.BaseDir]; if (!Directory.Exists(section.Service.BaseDir)) { Directory.CreateDirectory(section.Service.BaseDir); } } if (!string.IsNullOrEmpty(Context.Parameters[Argument.Index])) { section.Service.Index = int.Parse(Context.Parameters[Argument.Index], CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(Context.Parameters[Argument.StatusPort])) { int port = Convert.ToInt32(Context.Parameters[Argument.StatusPort], CultureInfo.InvariantCulture); section.Service.StatusPort = port; if (port != 0) { FirewallTools.OpenPort(port, "FileService Status"); } } if (!string.IsNullOrEmpty(Context.Parameters[Argument.LocalDb])) { section.Service.LocalDB = Context.Parameters[Argument.LocalDb]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.LocalRoute])) { section.Service.LocalRoute = Context.Parameters[Argument.LocalRoute]; } else { string ip = string.Empty; foreach (IPAddress address in Dns.GetHostEntry(Dns.GetHostName()).AddressList) { if (address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { ip = address.ToString(); break; } } section.Service.LocalRoute = ip; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.Mbus])) { section.Service.MBus = Context.Parameters[Argument.Mbus]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.MigrationNfs])) { section.Service.MigrationNFS = Context.Parameters[Argument.MigrationNfs]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.NodeId])) { section.Service.NodeId = Context.Parameters[Argument.NodeId]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.ZInterval])) { section.Service.ZInterval = int.Parse(Context.Parameters[Argument.ZInterval], CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(Context.Parameters[Argument.Plan])) { section.Service.Plan = Context.Parameters[Argument.Plan]; } if (!string.IsNullOrEmpty(Context.Parameters[Argument.UseVhd])) { section.Service.Uhurufs.UseVHD = bool.Parse(Context.Parameters[Argument.UseVhd]); } if (!string.IsNullOrEmpty(Context.Parameters[Argument.MaxStorageSize])) { section.Service.Uhurufs.MaxStorageSize = long.Parse(Context.Parameters[Argument.MaxStorageSize], CultureInfo.InvariantCulture); } if (!string.IsNullOrEmpty(Context.Parameters[Argument.VhdFixedSize])) { section.Service.Uhurufs.VHDFixedSize = bool.Parse(Context.Parameters[Argument.VhdFixedSize]); } section.DEA = null; config.Save(); int lowPort = 5000; int highPort = 6000; using (ServerManager serverManager = new ServerManager()) { Microsoft.Web.Administration.Configuration iisConfig = serverManager.GetApplicationHostConfiguration(); Microsoft.Web.Administration.ConfigurationSection firewallSupportSection = iisConfig.GetSection("system.ftpServer/firewallSupport"); firewallSupportSection["lowDataChannelPort"] = lowPort; firewallSupportSection["highDataChannelPort"] = highPort; Microsoft.Web.Administration.ConfigurationSection sitesSection = iisConfig.GetSection("system.applicationHost/sites"); Microsoft.Web.Administration.ConfigurationElement siteDefaultsElement = sitesSection.GetChildElement("siteDefaults"); Microsoft.Web.Administration.ConfigurationElement ftpServerElement = siteDefaultsElement.GetChildElement("ftpServer"); Microsoft.Web.Administration.ConfigurationElement firewallSupportElement = ftpServerElement.GetChildElement("firewallSupport"); firewallSupportElement["externalIp4Address"] = @"0.0.0.0"; serverManager.CommitChanges(); } FirewallTools.OpenPortRange(lowPort, highPort, "UhuruFS Ports"); }