Esempio n. 1
0
        void ProcessLocalQueue(DeploymentResult result)
        {
            Logging.Coarse("[msmq] Setting default permissions for on local queue '{0}'", _address.ActualUri);

            try
            {
                var q = new MessageQueue(_address.LocalName);

                q.SetPermissions(WellKnownSecurityRoles.Administrators, MessageQueueAccessRights.FullControl, AccessControlEntryType.Allow);
                result.AddGood("Successfully set permissions for '{0}' on queue '{1}'".FormatWith(WellKnownSecurityRoles.Administrators, _address.LocalName));

                q.SetPermissions(WellKnownSecurityRoles.CurrentUser, MessageQueueAccessRights.FullControl, AccessControlEntryType.Revoke);
                result.AddGood("Successfully set permissions for '{0}' on queue '{1}'".FormatWith(WellKnownSecurityRoles.Administrators, _address.LocalName));

                q.SetPermissions(WellKnownSecurityRoles.Everyone, MessageQueueAccessRights.FullControl, AccessControlEntryType.Revoke);
                result.AddGood("Successfully set permissions for '{0}' on queue '{1}'".FormatWith(WellKnownSecurityRoles.Administrators, _address.LocalName));

                q.SetPermissions(WellKnownSecurityRoles.Anonymous, MessageQueueAccessRights.FullControl, AccessControlEntryType.Revoke);
                result.AddGood("Successfully set permissions for '{0}' on queue '{1}'".FormatWith(WellKnownSecurityRoles.Administrators, _address.LocalName));
            }
            catch (MessageQueueException ex)
            {
                if (ex.Message.Contains("does not exist"))
                {
                    throw new DeploymentException("The queue '{0}' doesn't exist.", ex);
                }

                throw;
            }
        }
Esempio n. 2
0
        public void CheckForSiteAndVDirExistance(Func <bool> website, Func <bool> vdir, DeploymentResult result)
        {
            if (website())
            {
                result.AddGood("Found Website '{0}'", WebsiteName);

                if (vdir())
                {
                    result.AddGood("Found VDir '{0}'", VdirPath);
                }
                else
                {
                    result.AddAlert("Couldn't find VDir '{0}'", VdirPath);

                    if (ShouldCreate)
                    {
                        result.AddAlert("The VDir '{0}' will be created", VdirPath);
                    }
                }
            }
            else
            {
                result.AddAlert("Couldn't find Website '{0}'", WebsiteName);

                if (ShouldCreate)
                {
                    result.AddAlert("Website '{0}' and VDir '{1}' will be created", WebsiteName, VdirPath);
                }
            }
        }
Esempio n. 3
0
        public void CheckForSiteAndVDirExistance(Func<bool> website, Func<bool> vdir, DeploymentResult result)
        {
            if (website())
            {
                result.AddGood("Found Website '{0}'", WebsiteName);

                if (vdir())
                {
                    result.AddGood("Found VDir '{0}'", VdirPath);
                }
                else
                {
                    result.AddAlert("Couldn't find VDir '{0}'", VdirPath);

                    if (ShouldCreate)
                        result.AddAlert("The VDir '{0}' will be created", VdirPath);
                }
            }
            else
            {
                result.AddAlert("Couldn't find Website '{0}'", WebsiteName);

                if (ShouldCreate)
                    result.AddAlert("Website '{0}' and VDir '{1}' will be created", WebsiteName, VdirPath);
            }
        }
Esempio n. 4
0
        void ProcessLocalQueue(DeploymentResult result)
        {
            Logging.Coarse("[msmq] Setting default permissions for on local queue '{0}'", _address.ActualUri);

            try
            {
                var q = new MessageQueue(_address.LocalName);

                q.SetPermissions(WellKnownSecurityRoles.Administrators, MessageQueueAccessRights.FullControl, AccessControlEntryType.Allow);
                result.AddGood("Successfully set permissions for '{0}' on queue '{1}'".FormatWith(WellKnownSecurityRoles.Administrators, _address.LocalName));

                q.SetPermissions(WellKnownSecurityRoles.CurrentUser, MessageQueueAccessRights.FullControl, AccessControlEntryType.Revoke);
                result.AddGood("Successfully set permissions for '{0}' on queue '{1}'".FormatWith(WellKnownSecurityRoles.Administrators, _address.LocalName));

                q.SetPermissions(WellKnownSecurityRoles.Everyone, MessageQueueAccessRights.FullControl, AccessControlEntryType.Revoke);
                result.AddGood("Successfully set permissions for '{0}' on queue '{1}'".FormatWith(WellKnownSecurityRoles.Administrators, _address.LocalName));

                q.SetPermissions(WellKnownSecurityRoles.Anonymous, MessageQueueAccessRights.FullControl, AccessControlEntryType.Revoke);
                result.AddGood("Successfully set permissions for '{0}' on queue '{1}'".FormatWith(WellKnownSecurityRoles.Administrators, _address.LocalName));
            }
            catch (MessageQueueException ex)
            {
                if (ex.Message.Contains("does not exist")) throw new DeploymentException("The queue '{0}' doesn't exist.", ex);

                throw;
            }


        }
Esempio n. 5
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            if (ServiceExists())
            {
                if (!dropkick.Wmi.WmiService.AuthenticationSpecified)
                {
                    using (var c = new ServiceController(ServiceName, MachineName))
                    {
                        Logging.Coarse("[svc] Stopping service '{0}'", ServiceName);
                        if (c.CanStop)
                        {
                            int pid = GetProcessId(ServiceName);

                            c.Stop();
                            c.WaitForStatus(ServiceControllerStatus.Stopped, 30.Seconds());

                            WaitForProcessToDie(pid);
                        }
                    }
                    result.AddGood("Stopped Service '{0}'", ServiceName);
                    Logging.Coarse("[svc] Stopped service '{0}'", ServiceName);
                }
                else
                {
                    if (!ServiceIsRunning())
                    {
                        result.AddGood("Stopping Service '{0}', Service Already Stopped", ServiceName);
                        Logging.Coarse("[svc] Stopping service '{0}', service already stopped", ServiceName);
                    }
                    else
                    {
                        var status = dropkick.Wmi.WmiService.Stop(MachineName, ServiceName);
                        switch (status)
                        {
                        case Wmi.ServiceReturnCode.StatusServiceExists:
                        case Wmi.ServiceReturnCode.Success:
                            result.AddGood("Stopped Service '{0}'", ServiceName);
                            Logging.Coarse("[svc] Stopped service '{0}'", ServiceName);
                            break;

                        default:
                            //BAD
                            throw new Exception("Failed to stop service {0}: {1}".FormatWith(ServiceName, status));
                        }
                    }
                    result.AddGood("Stopped Service '{0}'", ServiceName);
                    Logging.Coarse("[svc] Stopped service '{0}'", ServiceName);
                }
            }
            else
            {
                result.AddAlert("Service '{0}' does not exist and could not be stopped", ServiceName);
                Logging.Coarse("[svc] Service '{0}' does not exist.", ServiceName);
            }

            return(result);
        }
Esempio n. 6
0
		public DeploymentResult VerifyCanRun()
		{
			var result = new DeploymentResult();

			if (File.Exists(System.IO.Path.GetFileName(_fileName)))
			{
				result.AddGood(string.Format("{0} exists and will be deleted.", _fileName));
			}
			else
			{
				result.AddGood(string.Format("{0} does not exist, so cannot be deleted.", _fileName));
			}

			return result;
		}
Esempio n. 7
0
        public DeploymentResult Execute()
        {
            var result = new DeploymentResult();
            var to = _path.GetFullPath(_to);

            if (Directory.Exists(to))
                result.AddGood("'{0}' already exists.".FormatWith(to));
            else
            {
                result.AddGood(Name);
                Directory.CreateDirectory(to);
            }

            return result;
        }
Esempio n. 8
0
        public DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            if (File.Exists(System.IO.Path.GetFileName(_fileName)))
            {
                result.AddGood(string.Format("{0} exists and will be deleted.", _fileName));
            }
            else
            {
                result.AddGood(string.Format("{0} does not exist, so cannot be deleted.", _fileName));
            }

            return(result);
        }
Esempio n. 9
0
        public DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            if (File.Exists(_fileName))
            {
                File.Delete(_fileName);
                result.AddGood(string.Format("{0} exists and was deleted.", _fileName));
            }
            else
            {
                result.AddGood(string.Format("{0} does not exist, so cannot be deleted.", _fileName));
            }

            return(result);
        }
Esempio n. 10
0
        public DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            var psi = new ProcessStartInfo(Command, Args);

            psi.UseShellExecute        = false;
            psi.CreateNoWindow         = true;
            psi.RedirectStandardOutput = true;

            if (!string.IsNullOrEmpty(WorkingDirectory))
            {
                psi.WorkingDirectory = WorkingDirectory;
            }

            string output;

            using (Process p = Process.Start(psi))
            {
                //what to do here?
                p.WaitForExit(30.Seconds().Milliseconds);
                output = p.StandardOutput.ReadToEnd();
            }

            result.AddGood("Command Line Executed");

            return(result);
        }
Esempio n. 11
0
        void BuildApplicationPool(ServerManager mgr, DeploymentResult result)
        {
            if (string.IsNullOrEmpty(AppPoolName))
            {
                return;
            }

            if (mgr.ApplicationPools.Any(x => x.Name == AppPoolName))
            {
                LogIis("[iis7] Found the AppPool '{0}' skipping work", AppPoolName);
                return;
            }

            var pool = mgr.ApplicationPools.Add(AppPoolName);

            if (Enable32BitAppOnWin64)
            {
                pool.Enable32BitAppOnWin64 = true;
            }

            pool.ManagedRuntimeVersion = ManagedRuntimeVersion;

            if (UseClassicPipeline)
            {
                pool.ManagedPipelineMode = ManagedPipelineMode.Classic;
            }

            LogIis("[iis7] Created app pool '{0}'", AppPoolName);
            result.AddGood("Created app pool '{0}'", AppPoolName);
        }
Esempio n. 12
0
        public DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            try
            {
                File.GetAttributes(_target);
                result.AddGood(string.Format("{0} exists and will be deleted.", _target));
            }
            catch (Exception ex)
            {
                result.AddGood(string.Format("{0} does not exist, deletion skipped.", _target));
            }

            return result;
        }
Esempio n. 13
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            //can I connect to the server?

            IDbConnection conn = null;
            try
            {
                conn = GetConnection();
                conn.Open();
                result.AddGood("I can talk to the database");
            }
            catch (Exception)
            {
                result.AddAlert("I cannot open the connection");
                throw;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                    conn.Dispose();
                }
            }

            //can I connect to the database?
            if (OutputSql != null)
                result.AddAlert(string.Format("I will run the sql '{0}'", OutputSql));


            return result;
        }
Esempio n. 14
0
        public DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            ValidatePath(result, _to);
            ValidatePath(result, _from);

            _from = Path.GetFullPath(_from);
            _to = Path.GetFullPath(_to);

            //todo: verify that from exists
            if (!Directory.Exists(_to))
            {
                Directory.CreateDirectory(_to);
            }

            if (Directory.Exists(_from))
            {
                foreach (string file in Directory.GetFiles(_from))
                {
                    //need to support recursion
                    string fileName = Path.GetFileName(file);
                    File.Copy(file, Path.Combine(_to, fileName));
                    //log file was copied / event?
                }

                //what do you want to do if the directory DOESN'T exist?
            }

            result.AddGood("Copied stuff");

            return result;
        }
Esempio n. 15
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            ValidatePath(result, _to);
            ValidatePath(result, _from);

            _from = _path.GetFullPath(_from);
            _to   = _path.GetFullPath(_to);

            if (_clearOptions == DestinationCleanOptions.Delete)
            {
                DeleteDestinationFirst(new DirectoryInfo(_to), result);
            }
            if (_clearOptions == DestinationCleanOptions.Clear)
            {
                CleanDirectoryContents(result, new DirectoryInfo(_to), _clearIgnorePatterns);
            }

            CopyDirectory(result, new DirectoryInfo(_from), new DirectoryInfo(_to), _copyIgnorePatterns);

            result.AddGood(Name);

            return(result);
        }
Esempio n. 16
0
		public override DeploymentResult VerifyCanRun()
		{
			var result = new DeploymentResult();
			ValidateIsFile(result, _filePath);
			result.AddGood(Name);
			return result;
		}
Esempio n. 17
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();
            var iisManager = ServerManager.OpenRemote(ServerName);
            BuildApplicationPool(iisManager, result);

            if (!DoesSiteExist(result)) CreateWebSite(iisManager, WebsiteName, result);

            Site site = GetSite(iisManager, WebsiteName);
        	BuildVirtualDirectory(site, iisManager, result);

        	try
        	{
				iisManager.CommitChanges();
                result.AddGood("'{0}' was created/updated successfully.", VirtualDirectoryPath);
        	}
        	catch (COMException ex)
        	{
        		if (ProcessModelIdentityType == ProcessModelIdentityType.SpecificUser) throw new DeploymentException("An exception occurred trying to apply deployment changes. If you are attempting to set the IIS " +
						"Process Model's identity to a specific user then ensure that you are running DropKick with elevated privileges, or UAC is disabled.", ex);
        		throw;
        	}
        	LogCoarseGrain("[iis7] {0}", Name);
            
            return result;
        }
Esempio n. 18
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            if (ServiceExists())
            {
                using (var c = new ServiceController(ServiceName, MachineName))
                {
                    Logging.Coarse("[svc] Stopping service '{0}'", ServiceName);
                    if (c.CanStop)
                    {
                        int pid = GetProcessId(ServiceName);

                        c.Stop();
                        c.WaitForStatus(ServiceControllerStatus.Stopped, 30.Seconds());

                        //WaitForProcessToDie(pid);
                    }
                }
                result.AddGood("Stopped Service '{0}'", ServiceName);
                Logging.Coarse("[svc] Stopped service '{0}'", ServiceName);
            }
            else
            {
                result.AddAlert("Service '{0}' does not exist and could not be stopped", ServiceName);
                Logging.Coarse("[svc] Service '{0}' does not exist.", ServiceName);
            }

            return result;
        }
Esempio n. 19
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            var iisManager = ServerManager.OpenRemote(ServerName);

            BuildApplicationPool(iisManager, result);

            if (!DoesSiteExist(result))
            {
                CreateWebSite(iisManager, WebsiteName, result);
            }


            Site site = GetSite(iisManager, WebsiteName);

            if (!DoesVirtualDirectoryExist(site))
            {
                result.AddAlert("'{0}' doesn't exist. creating.", VdirPath);
                CreateVirtualDirectory(site, iisManager);
                result.AddGood("'{0}' was created", VdirPath);
            }


            iisManager.CommitChanges();
            LogCoarseGrain("[iis7] {0}", Name);
            return(result);
        }
Esempio n. 20
0
        public override DeploymentResult Execute()
        {
            var result     = new DeploymentResult();
            var iisManager = ServerManager.OpenRemote(ServerName);

            BuildApplicationPool(iisManager, result);

            if (!DoesSiteExist(result))
            {
                CreateWebSite(iisManager, WebsiteName, result);
            }

            Site site = GetSite(iisManager, WebsiteName);

            BuildVirtualDirectory(site, iisManager, result);

            try
            {
                iisManager.CommitChanges();
                result.AddGood("'{0}' was created/updated successfully.", VirtualDirectoryPath);
            }
            catch (COMException ex)
            {
                if (ProcessModelIdentityType == ProcessModelIdentityType.SpecificUser)
                {
                    throw new DeploymentException("An exception occurred trying to apply deployment changes. If you are attempting to set the IIS " +
                                                  "Process Model's identity to a specific user then ensure that you are running DropKick with elevated privileges, or UAC is disabled.", ex);
                }
                throw;
            }
            LogCoarseGrain("[iis7] {0}", Name);

            return(result);
        }
Esempio n. 21
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            if (ServiceExists())
            {
                using (var c = new ServiceController(ServiceName, MachineName))
                {
                    Logging.Coarse("[svc] Stopping service '{0}'", ServiceName);
                    if (c.CanStop)
                    {
                        int pid = GetProcessId(ServiceName);

                        c.Stop();
                        c.WaitForStatus(ServiceControllerStatus.Stopped, 30.Seconds());

                        WaitForProcessToDie(pid);
                    }
                }
                result.AddGood("Stopped Service '{0}'", ServiceName);
                Logging.Coarse("[svc] Stopped service '{0}'", ServiceName);
            }
            else
            {
                result.AddAlert("Service '{0}' does not exist and could not be stopped", ServiceName);
                Logging.Coarse("[svc] Service '{0}' does not exist.", ServiceName);
            }

            return(result);
        }
Esempio n. 22
0
 public DeploymentResult Execute()
 {
     Thread.Sleep(_waitTime);
     var result = new DeploymentResult();
     result.AddGood("Waited for '{0}' seconds", _waitTime.TotalSeconds.ToString());
     return result;
 }
Esempio n. 23
0
        public DeploymentResult Execute()
        {
            var result          = new DeploymentResult();
            var managementClass = new ManagementClass("Win32_Share");

            ManagementBaseObject args = managementClass.GetMethodParameters("Create");

            args["Description"] = Description;
            args["Name"]        = ShareName;
            args["Path"]        = PointingTo;
            args["Type"]        = 0x0; // Disk Drive

            ManagementBaseObject outParams = managementClass.InvokeMethod("Create", args, null);

            // Check to see if the method invocation was successful
            if (outParams != null && (uint)(outParams.Properties["ReturnValue"].Value) != 0)
            {
                throw new Exception("Unable to share directory '{0}' as '{2}' on '{1}'.".FormatWith(PointingTo, Server,
                                                                                                    ShareName));
            }

            result.AddGood("Created share");

            return(result);
        }
Esempio n. 24
0
		public DeploymentResult Execute()
		{
			var result = new DeploymentResult();

			if (File.Exists(_fileName))
			{
				File.Delete(_fileName);
				result.AddGood(string.Format("{0} exists and was deleted.", _fileName));
			}
			else
			{
				result.AddGood(string.Format("{0} does not exist, so cannot be deleted.", _fileName));
			}

			return result;
		}
Esempio n. 25
0
        public DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            ValidatePath(result, _to);
            ValidatePath(result, _from);

            _from = Path.GetFullPath(_from);
            _to   = Path.GetFullPath(_to);

            //todo: verify that from exists
            if (!Directory.Exists(_to))
            {
                Directory.CreateDirectory(_to);
            }

            if (Directory.Exists(_from))
            {
                foreach (string file in Directory.GetFiles(_from))
                {
                    //need to support recursion
                    string fileName = Path.GetFileName(file);
                    File.Copy(file, Path.Combine(_to, fileName));
                    //log file was copied / event?
                }

                //what do you want to do if the directory DOESN'T exist?
            }

            result.AddGood("Copied stuff");

            return(result);
        }
Esempio n. 26
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            if (UserName.ShouldPrompt())
            {
                UserName = _prompt.Prompt("Win Service '{0}' UserName".FormatWith(ServiceName));
            }

            if (Password.ShouldPrompt())
            {
                Password = _prompt.Prompt("Win Service '{0}' For User '{1}' Password".FormatWith(ServiceName, UserName));
            }

            ServiceReturnCode returnCode = WmiService.Create(MachineName, ServiceName, ServiceDisplayName, ServiceLocation,
                                                             StartMode, UserName, Password, Dependencies);

            if (returnCode != ServiceReturnCode.Success)
            {
                result.AddAlert("Create service returned {0}".FormatWith(returnCode.ToString()));
            }
            else
            {
                result.AddGood("Create service succeeded.");
            }

            return(result);
        }
Esempio n. 27
0
        public DeploymentResult Execute()
        {
            var result = new DeploymentResult();
            var to     = _path.GetFullPath(_to);

            if (Directory.Exists(to))
            {
                result.AddGood("'{0}' already exists.".FormatWith(to));
            }
            else
            {
                result.AddGood(Name);
                Directory.CreateDirectory(to);
            }

            return(result);
        }
Esempio n. 28
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            ValidateIsFile(result, _filePath);
            result.AddGood(Name);
            return(result);
        }
Esempio n. 29
0
        public DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            ValidatePath(result, _to);
            ValidatePath(result, _from);

            _from = Path.GetFullPath(_from);
            _to   = Path.GetFullPath(_to);

            //check can write from _to
            if (!Directory.Exists(_to))
            {
                result.AddAlert(string.Format("'{0}' doesn't exist and will be created", _to));
            }

            if (Directory.Exists(_from))
            {
                result.AddGood(string.Format("'{0}' exists", _from));
                //check can read from _from
                string[] readFiles = Directory.GetFiles(_from);
                foreach (string file in readFiles)
                {
                    Stream fs = new MemoryStream();
                    try
                    {
                        fs = File.Open(file, FileMode.Open, FileAccess.Read);
                        result.AddGood(string.Format("Going to copy '{0}' to '{1}'", file, _to));
                    }
                    catch (Exception)
                    {
                        result.AddAlert("CopyTask: Can't read file '{0}'");
                    }
                    finally
                    {
                        fs.Dispose();
                    }
                }
            }
            else
            {
                result.AddAlert(string.Format("'{0}' doesn't exist", _from));
            }

            return(result);
        }
Esempio n. 30
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            if (!MessageQueue.Exists(Address.LocalName))
            {
                result.AddAlert("'{0}' does not exist and will be created.".FormatWith(Address.FormatName));
                MessageQueue.Create(Address.LocalName);
                result.AddGood("Created queue '{0}'".FormatWith(Address.FormatName));
            }
            else
            {
                result.AddGood("'{0}' already exists.".FormatWith(Address.FormatName));
            }

            return(result);
        }
Esempio n. 31
0
 public DeploymentResult VerifyCanRun()
 {
     var result = new DeploymentResult();
     var to = _path.GetFullPath(_to);
     //TODO figure out a good verify step...
     result.AddGood(Directory.Exists(to) ? "'{0}' already exists.".FormatWith(to) : Name);
     return result;
 }
Esempio n. 32
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            if (!MessageQueue.Exists(Address.LocalName))
            {
                result.AddAlert("'{0}' does not exist and will be created.".FormatWith(Address.FormatName));
                MessageQueue.Create(Address.LocalName, _transactional);
                result.AddGood("Created queue '{0}'".FormatWith(Address.FormatName));
            }
            else
            {
                result.AddGood("'{0}' already exists.".FormatWith(Address.FormatName));
            }

            return result;
        }
Esempio n. 33
0
        public DeploymentResult Execute()
        {
            Thread.Sleep(_waitTime);
            var result = new DeploymentResult();

            result.AddGood("Waited for '{0}' seconds", _waitTime.TotalSeconds.ToString());
            return(result);
        }
Esempio n. 34
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            ValidatePath(result, _to);
            ValidatePath(result, _from);

            _from = _path.GetFullPath(_from);
            _to   = _path.GetFullPath(_to);

            //check can write from _to
            if (_path.DirectoryDoesntExist(_to))
            {
                result.AddAlert(string.Format("'{0}' doesn't exist and will be created", _to));
            }

            if (_clearOptions == DestinationCleanOptions.Delete)
            {
                result.AddAlert("The files and directories in '{0}' will be deleted before deploying, except for items being ignored.", _to);
            }
            if (_clearOptions == DestinationCleanOptions.Clear)
            {
                result.AddAlert("The files in '{0}' will be cleared before deploying, except for items being ignored.", _to);
            }

            DirectoryInfo fromDirectory = new DirectoryInfo(_from);

            if (fromDirectory.Exists)
            {
                result.AddGood(string.Format("'{0}' exists", fromDirectory.FullName));

                //check can read from _from
                FileInfo[] readFiles = fromDirectory.GetFiles();
                foreach (var file in readFiles.Where(f => !IsIgnored(_copyIgnorePatterns, f)))
                {
                    Stream fs = new MemoryStream();
                    try
                    {
                        fs = File.Open(file.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        _log.DebugFormat("Going to copy '{0}' to '{1}'", file.FullName, _to);
                    }
                    catch (Exception)
                    {
                        result.AddAlert("CopyDirectoryTask: Can't read file '{0}'");
                    }
                    finally
                    {
                        fs.Dispose();
                    }
                }
            }
            else
            {
                result.AddAlert(string.Format("'{0}' doesn't exist", _from));
            }

            return(result);
        }
Esempio n. 35
0
        public DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();
            var to     = _path.GetFullPath(_to);

            //TODO figure out a good verify step...
            result.AddGood(Directory.Exists(to) ? "'{0}' already exists.".FormatWith(to) : Name);
            return(result);
        }
Esempio n. 36
0
 protected static void DeleteDestinationFirst(DirectoryInfo directory, DeploymentResult result)
 {
     if (directory.Exists)
     {
         directory.Delete(true);
         result.AddGood("'{0}' was successfully deleted".FormatWith(directory.FullName));
         //TODO: a delete list?
     }
 }
Esempio n. 37
0
 protected static void DeleteDestinationFirst(DirectoryInfo directory, DeploymentResult result)
 {
     if (directory.Exists)
     {
         directory.Delete(true);
         result.AddGood("'{0}' was successfully deleted".FormatWith(directory.FullName));
         //TODO: a delete list?
     }
 }
Esempio n. 38
0
        void BuildApplicationPool(ServerManager mgr, DeploymentResult result)
        {
            if (string.IsNullOrEmpty(AppPoolName))
            {
                return;
            }

            ApplicationPool pool = mgr.ApplicationPools.FirstOrDefault(x => x.Name == AppPoolName);

            if (pool == null)
            {
                LogIis("App pool '{0}' does not exist, creating.", AppPoolName);
                pool = mgr.ApplicationPools.Add(AppPoolName);
            }
            else
            {
                LogIis("[iis7] Found the AppPool '{0}', updating as necessary.", AppPoolName);
            }

            if (Enable32BitAppOnWin64)
            {
                pool.Enable32BitAppOnWin64 = true;
                LogIis("[iis7] Enabling 32bit application on Win64.");
            }

            pool.ManagedRuntimeVersion = ManagedRuntimeVersion;
            LogIis("[iis7] Using managed runtime version '{0}'", ManagedRuntimeVersion);

            if (UseClassicPipeline)
            {
                pool.ManagedPipelineMode = ManagedPipelineMode.Classic;
                LogIis("[iis7] Using Classic managed pipeline mode.");
            }

            result.AddGood("App pool '{0}' created/updated.", AppPoolName);

            if (SetProcessModelIdentity)
            {
                SetApplicationPoolIdentity(pool);
                result.AddGood("Set process model identity '{0}'", ProcessModelIdentityType);
            }

            //pool.Recycle();
        }
Esempio n. 39
0
		private void testArchive(DeploymentResult result)
		{
			if (!ZipFile.IsZipFile(_zipArchiveFilename))
				result.AddError(String.Format("The file '{0}' is not a valid zip archive.", _zipArchiveFilename));

			using (var zip = ZipFile.Read(_zipArchiveFilename))
			{
				result.AddGood("{0} items will be extracted from '{1}' to '{2}'", zip.Count, _zipArchiveFilename, _to);
			}
		}
Esempio n. 40
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            VerifyRegistryHivePermissions(result);

            result.AddGood(Name);

            return(result);
        }
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            VerifyRegistryHivePermissions(result);

            result.AddGood(Name);

            return result;
        }
Esempio n. 42
0
        public DeploymentResult VerifyCanRun()
        {
            //verify admin
            var result = new DeploymentResult();

            if (!Directory.Exists(PointingTo)) result.AddAlert("'{0}' doesn't exist", PointingTo);
            else result.AddGood("'{0}' exists", PointingTo);

            return result;
        }
Esempio n. 43
0
 void VerifyInAdministratorRole(DeploymentResult result)
 {
     if (Thread.CurrentPrincipal.IsInRole("Administrator"))
     {
         result.AddAlert("You are not in the Administrator role");
     }
     else
     {
         result.AddGood("You are in the Administrator role");
     }
 }
Esempio n. 44
0
 private void VerifyInAdministratorRole(DeploymentResult result)
 {
     if (Thread.CurrentPrincipal.IsInRole("Administrator"))
     {
         result.AddAlert("You are not in the Administrator role");
     }
     else
     {
         result.AddGood("You are in the Administrator role");
     }
 }
Esempio n. 45
0
 protected void VerifyInAdministratorRole(DeploymentResult result)
 {
     if (Thread.CurrentPrincipal.IsInRole("Administrator"))
     {
         result.AddAlert("You are not in the 'Administrator' role. You will not be able to start/stop services");
     }
     else
     {
         result.AddGood("You are in the 'Administrator' role");
     }
 }
Esempio n. 46
0
        void ProcessLocalQueue(DeploymentResult result)
        {
            Logging.Coarse("[msmq] Setting permissions for '{0}' on local queue '{1}'", _group, _address.ActualUri);

            var q = new MessageQueue(_address.FormatName);
            q.SetPermissions(_group, MessageQueueAccessRights.GetQueuePermissions, AccessControlEntryType.Allow);
            q.SetPermissions(_group, MessageQueueAccessRights.GetQueueProperties, AccessControlEntryType.Allow);
            q.SetPermissions(_group, MessageQueueAccessRights.WriteMessage, AccessControlEntryType.Allow);

            result.AddGood("Successfully granted Write permissions to '{0}' for queue '{1}'".FormatWith(_group, _address.ActualUri));
        }
Esempio n. 47
0
        public DeploymentResult Execute()
        {
            Console.WriteLine();
            Console.WriteLine(Name);
            Console.WriteLine("Press enter to continue.");
            Console.ReadLine();

            var result = new DeploymentResult();
            result.AddGood("User pressed enter to continue deployment.");
            return result;
        }
Esempio n. 48
0
        protected void DeleteDestinationFirst(DirectoryInfo directory, DeploymentResult result)
        {
            if (directory.Exists)
            {
                RemoveReadOnlyAttributes(directory, result);

                directory.Delete(true);
                result.AddGood("'{0}' was successfully deleted".FormatWith(directory.FullName));
                //TODO: a delete list?
            }
        }
Esempio n. 49
0
 protected void VerifyInAdministratorRole(DeploymentResult result)
 {
     if (Thread.CurrentPrincipal.IsInRole("Administrator"))
     {
         result.AddAlert("You are not in the 'Administrator' role. You will not be able to start/stop services");
     }
     else
     {
         result.AddGood("You are in the 'Administrator' role");
     }
 }
Esempio n. 50
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            _filePath = _path.GetFullPath(_filePath);
            ValidateIsFile(result, _filePath);

            UpdateXmlFile(result, _filePath, _replacementItems);

            result.AddGood(Name);
            return result;
        }
Esempio n. 51
0
        public DeploymentResult Execute()
        {
            Console.WriteLine();
            Console.WriteLine(Name);
            Console.WriteLine("Press enter to continue.");
            Console.ReadLine();

            var result = new DeploymentResult();

            result.AddGood("User pressed enter to continue deployment.");
            return(result);
        }
Esempio n. 52
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            if (_address.IsLocal)
                VerifyInAdministratorRole(result);
            else
                result.AddAlert("Cannot set permissions for the private remote queue '{0}' while on server '{1}'".FormatWith(_address.ActualUri, Environment.MachineName));

            result.AddGood(Name);
            return result;
        }
Esempio n. 53
0
        void ProcessLocalQueue(DeploymentResult result)
        {
            Logging.Coarse("[msmq] Setting permissions for '{0}' on local queue '{1}'", _group, _address.ActualUri);

            var q = new MessageQueue(_address.FormatName);

            q.SetPermissions(_group, MessageQueueAccessRights.GetQueuePermissions, AccessControlEntryType.Allow);
            q.SetPermissions(_group, MessageQueueAccessRights.GetQueueProperties, AccessControlEntryType.Allow);
            q.SetPermissions(_group, MessageQueueAccessRights.WriteMessage, AccessControlEntryType.Allow);

            result.AddGood("Successfully granted Write permissions to '{0}' for queue '{1}'".FormatWith(_group, _address.ActualUri));
        }
Esempio n. 54
0
        public DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            if (!Directory.Exists(ExecutableIsLocatedAt))
                result.AddAlert(string.Format("Can't find the executable '{0}'", Path.Combine(ExecutableIsLocatedAt, Command)));

            if (IsTheExeInThisDirectory(ExecutableIsLocatedAt, Command))
                result.AddGood(string.Format("Found command '{0}' in '{1}'", Command, ExecutableIsLocatedAt));

            return result;
        }
Esempio n. 55
0
        public DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            ValidateFile(result, _target);

            RenameFile(new FileInfo(_target), new FileInfo(_newName));

            result.AddGood(Name);

            return result;
        }
Esempio n. 56
0
        private void testArchive(DeploymentResult result)
        {
            if (!ZipFile.IsZipFile(_zipArchiveFilename))
            {
                result.AddError(String.Format("The file '{0}' is not a valid zip archive.", _zipArchiveFilename));
            }

            using (var zip = ZipFile.Read(_zipArchiveFilename))
            {
                result.AddGood("{0} items will be extracted from '{1}' to '{2}'", zip.Count, _zipArchiveFilename, _to);
            }
        }
Esempio n. 57
0
        public override DeploymentResult VerifyCanRun()
        {
            var result = new DeploymentResult();

            _from = _path.GetFullPath(_from);
            _to = _path.GetFullPath(_to);

            ValidatePaths(result);

            result.AddGood(Name);

            return result;
        }
Esempio n. 58
0
        public DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            if ((File.GetAttributes(_target) & FileAttributes.Directory) == FileAttributes.Directory)
                RenameDirectory(new DirectoryInfo(_target), new DirectoryInfo(_newName));
            else
                RenameFile(new FileInfo(_target), new FileInfo(_newName));

            result.AddGood(Name);

            return result;
        }
Esempio n. 59
0
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            var security = Directory.GetAccessControl(_path);
            security.SetAccessRuleProtection(true, true);
            Directory.SetAccessControl(_path, security);

            LogSecurity("[security][acl] Removed ACL inheritance on '{0}'. Preserved existing security.",  _path);
            result.AddGood("Removed ACL inheritance on '{0}'. Preserved existing security.",  _path);

            return result;
        }
        public override DeploymentResult Execute()
        {
            var result = new DeploymentResult();

            Logging.Coarse("[msmq] Setting '{0}' access rights for '{1}' on local queue '{2}'", _accessRights, _user, _address.ActualUri);

            var q = new MessageQueue(_address.FormatName);
            q.SetPermissions(_user, _accessRights, AccessControlEntryType.Allow);

            result.AddGood("Successfully granted '{0}' access rights to '{1}' for queue '{2}'".FormatWith(_accessRights, _user, _address.ActualUri));

            return result;
        }