public override void Remove()
        {
            if (TargetFileSystem.FileExists(PathToConfig))
            {
                TargetFileSystem.DeleteFile(PathToConfig);
            }

            if (TargetFileSystem.DirectoryExists(InstallationPath) &&
                !string.Equals(LocalFileSystem.GetFullPath(BaselineSourcePath), TargetFileSystem.GetFullPath(InstallationPath), StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    TargetFileSystem.DeleteDirectory(InstallationPath);
                }
                catch (UnauthorizedAccessException)
                {
                    foreach (System.Diagnostics.Process p in Win32ProcessHelper.GetProcessesLockingFile(GetUnremovedFile(InstallationPath)))
                    {
                        Console.WriteLine("File is locked by Process(ID: {0}, NAME: {1}). Killing the process to unlock files", p.Id, p.ProcessName);
                        if (!p.WaitForExit(1000))
                        {
                            Win32ProcessHelper.TerminateProcess(p);
                            p.WaitForExit(5000);
                        }
                    }

                    TargetFileSystem.DeleteDirectory(InstallationPath);
                }
            }
        }
        protected void SetupNtfsPermissionsToFolder(string pathToFolder)
        {
            if (!TargetFileSystem.DirectoryExists(pathToFolder))
            {
                TargetFileSystem.CreateDirectory(pathToFolder);
            }

            ProcessWrapper.Execute("icacls", "\"{0}\" /grant *S-1-5-11:(OI)(CI)(M)", TargetFileSystem.GetFullPath(pathToFolder));
        }
        private void SetupConfig()
        {
            Logger.Instance.Log(LogLevel.Info, "\nSetting up config for component ({0}):\n", Id);

            SetupConfigFromTemplate(PathToConfig, PathToConfigTemplate);

            if (!string.IsNullOrEmpty(PathToBasicConfig))
            {
                Logger.Instance.Log(LogLevel.Info, "\tCreating basic config '{0}'",
                                    TargetFileSystem.GetFullPath(PathToBasicConfig));

                string configContent = string.Format(CultureInfo.InvariantCulture, "<ConfigFilePath value=\"{0}\" />", PathToConfig);
                TargetFileSystem.WriteAllTextToFile(PathToBasicConfig, configContent);
            }
        }
        protected void SetupConfigFromTemplate(string pathToConfig, string pathToTemplate)
        {
            if (LocalFileSystem.FileExists(pathToTemplate))
            {
                if (!TargetFileSystem.FileExists(pathToConfig))
                {
                    Logger.Instance.Log(LogLevel.Info, "\tCreating config '{0}' from '{1}' template",
                                        TargetFileSystem.GetFullPath(pathToConfig),
                                        LocalFileSystem.GetFullPath(pathToTemplate));

                    LocalFileSystem.CopyFile(pathToTemplate, TargetFileSystem, pathToConfig, true);
                }

                EnvironmentHelper.ExpandEnvironmentVariablesInConfig(pathToConfig, TargetFileSystem);
            }
        }
Exemplo n.º 5
0
 private void SetupVaultServerConfig()
 {
     Directory.CreateDirectory(PathToVaultFolder);
     TargetFileSystem.XmlHelper.XmlPoke(PathToConfig, "/configuration/appSettings/add[@key = 'LocalPath']/@value", PathToVaultFolder);
     ProcessWrapper.Execute("icacls", "{0} /grant *S-1-5-11:(OI)(CI)(M)", TargetFileSystem.GetFullPath(PathToVaultFolder));
 }
        public override void Setup()
        {
            base.Setup();

            TransferJobs(LocalFileSystem.GetFullPath(PathToConfigTemplate), TargetFileSystem.GetFullPath(PathToConfig));
        }