Exemple #1
0
        void EnableLoging(string destinationDirectory)
        {
            Console.WriteLine("Enabling logging.");

            if (!string.IsNullOrEmpty((destinationDirectory)))
            {
                if (File.Exists(destinationDirectory))
                {
                    Console.Error.WriteLine("{0} is a file, not a directory!");
                    Environment.Exit(1);
                }

                EnsureDirectoryExists(destinationDirectory);
            }

            ToolConfiguration toolConfig = ToolConfiguration.Load();

            LoggingConfiguration loggingConfig = toolConfig.LoggingConfig;

            loggingConfig.Enabled         = true;
            loggingConfig.DestinationPath = destinationDirectory;
            toolConfig.Save();

            Console.WriteLine(
                "Logging enabled. Logs will be saved to {0}.",
                loggingConfig.DestinationPath);
        }
        void ListDestinationAddresses()
        {
            ToolConfiguration  toolConfig  = ToolConfiguration.Load();
            EmailConfiguration emailConfig = toolConfig.EmailConfig;

            List <string> destinationAddresses = emailConfig.GetDestinationEmails();

            destinationAddresses.ForEach(address => Console.WriteLine(address));
        }
Exemple #3
0
        static Process BuildSyncServerTriggerProcessForUnixLike(string runArgs)
        {
            ToolConfiguration toolConfig = ToolConfiguration.Load();

            Process result = new Process();

            result.StartInfo.FileName  = toolConfig.RuntimeConfig.MonoRuntimePath;
            result.StartInfo.Arguments = $"{Utils.GetAssemblyLocation()} {runArgs}";
            return(result);
        }
Exemple #4
0
        void DeleteFilteredRepo(string repo)
        {
            Console.WriteLine("Deleting repository '{0}' from the filter list.", repo);

            ToolConfiguration toolConfig = ToolConfiguration.Load();

            toolConfig.RepoFilterConfig.DeleteFilteredRepo(repo);
            toolConfig.Save();

            Console.WriteLine("Repository '{0}' correctly deleted!", repo);
        }
Exemple #5
0
        void AddFilteredRepo(string repo)
        {
            Console.WriteLine("Adding repository '{0}' to the filter list.", repo);

            ToolConfiguration toolConfig = ToolConfiguration.Load();

            toolConfig.RepoFilterConfig.AddFilteredRepo(repo);
            toolConfig.Save();

            Console.WriteLine("Repository '{0}' correctly added!", repo);
        }
        void AddServer(string server)
        {
            Console.WriteLine("Adding server '{0}'.", server);

            ToolConfiguration toolConfig = ToolConfiguration.Load();

            toolConfig.ServerConfig.AddServer(server);
            toolConfig.Save();

            Console.WriteLine("Server '{0}' correctly added!", server);
        }
Exemple #7
0
        static void InitializeMonoRuntimePath()
        {
            ToolConfiguration toolConfig = ToolConfiguration.Load();

            toolConfig.RuntimeConfig.MonoRuntimePath =
                ConsoleUtils.ReadLine(
                    "Enter Mono runtime path",
                    PlatformUtils.DefaultMonoRuntimePath);

            toolConfig.Save();
        }
Exemple #8
0
        void DisableLogging()
        {
            Console.WriteLine("Disabling logging.");

            ToolConfiguration toolConfig = ToolConfiguration.Load();

            toolConfig.LoggingConfig.Enabled = false;
            toolConfig.Save();

            Console.WriteLine("Logging disabled.");
        }
        void DeleteServer(string server)
        {
            Console.WriteLine("Deleting server '{0}'", server);

            ToolConfiguration toolConfig = ToolConfiguration.Load();

            toolConfig.ServerConfig.DeleteServer(server);
            toolConfig.Save();

            Console.WriteLine("Server '{0}' correctly deleted!", server);
        }
        static void InitializeLogging()
        {
            ToolConfiguration    toolConfig    = ToolConfiguration.Load();
            LoggingConfiguration loggingConfig = toolConfig.LoggingConfig;

            if (!loggingConfig.Enabled)
            {
                return;
            }

            Logger.InitializeLoggerFile(loggingConfig.DestinationPath);
        }
        void AddDestinationAddress(string destinationAddress)
        {
            ToolConfiguration  toolConfig  = ToolConfiguration.Load();
            EmailConfiguration emailConfig = toolConfig.EmailConfig;

            emailConfig.AddDestinationEmail(destinationAddress);
            toolConfig.Save();

            Console.WriteLine(
                "Correctly added '{0}' to the destination addresses.",
                destinationAddress);
        }
        void DeleteDestinationAddress(string destinationAddress)
        {
            ToolConfiguration  toolConfig  = ToolConfiguration.Load();
            EmailConfiguration emailConfig = toolConfig.EmailConfig;

            emailConfig.RemoveDestinationEmail(destinationAddress);
            toolConfig.Save();

            Console.WriteLine(
                "Correctly removed '{0}' from the destination addresses.",
                destinationAddress);
        }
Exemple #13
0
        void ShowLoggingStatus()
        {
            ToolConfiguration    toolConfig    = ToolConfiguration.Load();
            LoggingConfiguration loggingConfig = toolConfig.LoggingConfig;

            Console.WriteLine(toolConfig.LoggingConfig.Enabled
                ? "Logging enabled."
                : "Logging disabled.");

            Console.WriteLine(
                "Logs destination path: {0}",
                toolConfig.LoggingConfig.DestinationPath);
        }
        void ListServers()
        {
            ToolConfiguration toolConfig = ToolConfiguration.Load();
            List <string>     servers    = toolConfig.ServerConfig.GetServers();

            if (servers.Count == 0)
            {
                Console.WriteLine("There are no configured destination servers.");
                return;
            }

            servers.ForEach(server => Console.WriteLine(server));
        }
        void ConfigureEmailWarnings()
        {
            ToolConfiguration  toolConfig  = ToolConfiguration.Load();
            EmailConfiguration emailConfig = toolConfig.EmailConfig;

            emailConfig.SmptServer  = ConsoleUtils.ReadLine("SMTP server address");
            emailConfig.EnableSsl   = ConsoleUtils.ReadBool("Enable SSL");
            emailConfig.Port        = ConsoleUtils.ReadInt("Port number");
            emailConfig.SourceEmail = ConsoleUtils.ReadLine("Email account");
            emailConfig.Password    = ConsoleUtils.ReadPassword("Password");

            toolConfig.Save();
            Console.WriteLine("The account was correctly configured!");
        }
Exemple #16
0
        void ListFilteredRepos()
        {
            ToolConfiguration toolConfig    = ToolConfiguration.Load();
            List <string>     filteredRepos =
                toolConfig.RepoFilterConfig.GetFilteredRepos();

            if (filteredRepos.Count == 0)
            {
                Console.WriteLine("There are no configured repo filters.");
                return;
            }

            filteredRepos.ForEach(repoFilter => Console.WriteLine(repoFilter));
        }
        void DeleteRepoMap(string srcRepo, string dstRepo, string dstServer)
        {
            RepoMapping mapping = new RepoMapping(srcRepo, dstRepo, dstServer);

            Console.WriteLine(
                "Deleting repository mapping '{0}' -> '{1}@{2}'",
                mapping.SrcRepo,
                mapping.DstRepo,
                mapping.DstServer);

            ToolConfiguration toolConfig = ToolConfiguration.Load();

            toolConfig.RepoMapConfig.DeleteMappedRepo(mapping);
            toolConfig.Save();

            Console.WriteLine("Repository mapping correctly deleted!");
        }
        void ListRepoMaps()
        {
            ToolConfiguration  toolConfig = ToolConfiguration.Load();
            List <RepoMapping> mappings   = toolConfig.RepoMapConfig.GetMappedRepos();

            if (mappings.Count == 0)
            {
                Console.WriteLine("There are no configured repo mappings.");
                return;
            }

            mappings.ForEach(
                repoMapping => Console.WriteLine(
                    "{0} -> {1}@{2}",
                    repoMapping.SrcRepo,
                    repoMapping.DstRepo,
                    repoMapping.DstServer));
        }
Exemple #19
0
        static string GetCommandLine(
            string triggerType, string triggerName, string executablePath, string server)
        {
            if (PlatformUtils.IsWindows)
            {
                return(string.Format(
                           "cm maketrigger {0} \"{1}\" \"{2} trigger {0}\" --server={3}",
                           triggerType,
                           triggerName,
                           executablePath,
                           server));
            }

            ToolConfiguration toolConfig = ToolConfiguration.Load();

            return(string.Format(
                       "cm maketrigger {0} \"{1}\" \"{2} {3} trigger {0}\" --server={4}",
                       triggerType,
                       triggerName,
                       toolConfig.RuntimeConfig.MonoRuntimePath,
                       executablePath,
                       server));
        }
Exemple #20
0
        void ICmd.Execute(string[] args)
        {
            if (args.Length == 1 || args.Length > 3)
            {
                Console.Error.WriteLine(HELP);
                Environment.Exit(1);
            }

            string srcServer = args[1];

            if (!Utils.CheckServerSpec(srcServer))
            {
                Console.Error.WriteLine(
                    "The server spec is not correct: {0}", srcServer);
                Environment.Exit(1);
            }

            Console.WriteLine(
                "Installing the necessary triggers on server {1}:{0}" +
                "* after-checkin{0}" +
                "* after-replicationwrite{0}" +
                "* after-mklabel{0}" +
                "* after-chattvalue",
                Environment.NewLine,
                srcServer);

            string executablePath = Utils.GetAssemblyLocation();

            Console.WriteLine(
                "Using syncservertrigger located at {0}.",
                executablePath);

            if (!PlatformUtils.IsWindows)
            {
                InitializeMonoRuntimePath();
            }

            if (!InstallTrigger(Trigger.Types.AfterCi, Trigger.Names.AfterCi, executablePath, srcServer) ||
                !InstallTrigger(Trigger.Types.AfterRW, Trigger.Names.AfterRW, executablePath, srcServer) ||
                !InstallTrigger(Trigger.Types.AfterMkLb, Trigger.Names.AfterMkLb, executablePath, srcServer) ||
                !InstallTrigger(Trigger.Types.AfterChAttVal, Trigger.Names.AfterChAttVal, executablePath, srcServer))
            {
                Environment.Exit(1);
            }

            Console.WriteLine(
                "Triggers successfully installed in {0}!", srcServer);

            if (args.Length != 3)
            {
                return;
            }

            string dstServer = args[2];

            if (!Utils.CheckServerSpec(dstServer))
            {
                Console.Error.WriteLine(
                    "The server spec is not correct: {0}",
                    dstServer);
                Environment.Exit(1);
            }

            Console.WriteLine(
                "Adding '{0}' as the first destination server.",
                dstServer);

            ToolConfiguration toolConfig = ToolConfiguration.Load();

            toolConfig.ServerConfig.AddServer(dstServer);
            toolConfig.Save();

            Console.WriteLine(
                "Server '{0}' correctly added!",
                dstServer);
        }
Exemple #21
0
        void ICmd.Execute(string[] args)
        {
            if (args.Length == 1 || args.Length > 5)
            {
                Logger.LogError(
                    $"RunCmd executed with wrong parameters: {string.Join(", ", args)}");
                Environment.Exit(1);
            }

            Logger.LogInfo("Started running...");

            ToolConfiguration  toolConfig    = ToolConfiguration.Load();
            List <string>      filteredRepos = toolConfig.RepoFilterConfig.GetFilteredRepos();
            List <string>      dstServers    = toolConfig.ServerConfig.GetServers();
            List <RepoMapping> repoMappings  = toolConfig.RepoMapConfig.GetMappedRepos();

            ErrorEmailSender emailSender =
                new ErrorEmailSender(toolConfig.EmailConfig);

            if (args.Length == 3 && args[1] == Trigger.Types.AfterCi)
            {
                RunAfterCheckin(
                    filteredRepos,
                    dstServers,
                    repoMappings,
                    args[2],
                    emailSender);
            }

            if (args.Length == 3 && args[1] == Trigger.Types.AfterRW)
            {
                RunAfterReplicationWrite(
                    filteredRepos,
                    dstServers,
                    repoMappings,
                    args[2],
                    emailSender);
            }

            if (args.Length == 5 && args[1] == Trigger.Types.AfterMkLb)
            {
                RunAfterMakeLabel(
                    filteredRepos,
                    dstServers,
                    repoMappings,
                    args[2],
                    args[3],
                    args[4],
                    emailSender);
            }

            if (args.Length == 5 && args[1] == Trigger.Types.AfterChAttVal)
            {
                RunAfterChangeAttributeValue(
                    filteredRepos,
                    dstServers,
                    repoMappings,
                    args[2],
                    args[3],
                    args[4],
                    emailSender);
            }
        }