Example #1
0
        static private void append_to_config_DECAC(Session session, string key, string value)
        {
            string MINION_CONFIGDIR = MinionConfigurationUtilities.getConfigdDirectoryLocation_DECAC(session);

            if (session.CustomActionData["config_type"] == "New")
            {
                //CONFIG_TYPE New creates a minion.d/*.conf file
                MinionConfigurationUtilities.Writeln_file(session, MINION_CONFIGDIR, key + ".conf", key + ": " + value);
            }
            else
            {
                // Shane: CONFIG_TYPES 1-3 change only the MINION_CONFIGFILE, not the minion.d/*.conf files, because the admin knows what he is doing.
                insert_value_after_comment_or_end_in_minionconfig_file(session, key, value);
            }
        }
Example #2
0
        private static bool replace_pattern_in_all_config_files_DECAC(Session session, string pattern, string replacement)
        {
            /*
             * "All config" files means:
             *   conf/minion
             *   conf/minion.d/*.conf           (only for New)
             *
             * MAYBE this function could input a dictionary of key/value pairs, because it reopens all config files over and over.
             *
             */
            bool   replaced_in_any_file = false;
            string MINION_CONFIGFILE    = MinionConfigurationUtilities.getConfigFileLocation_DECAC(session);
            string MINION_CONFIGDIR     = MinionConfigurationUtilities.getConfigdDirectoryLocation_DECAC(session);

            replaced_in_any_file |= replace_in_file_DECAC(session, MINION_CONFIGFILE, pattern, replacement);

            // Shane wants that the installer changes only the MINION_CONFIGFILE, not the minion.d/*.conf files
            if (session.CustomActionData["config_type"] == "New")
            {
                // Go into the minion.d/ folder
                if (Directory.Exists(MINION_CONFIGDIR))
                {
                    var conf_files = System.IO.Directory.GetFiles(MINION_CONFIGDIR, "*.conf");
                    foreach (var conf_file in conf_files)
                    {
                        // skip _schedule.conf
                        if (conf_file.EndsWith("_schedule.conf"))
                        {
                            continue;
                        }
                        replaced_in_any_file |= replace_in_file_DECAC(session, conf_file, pattern, replacement);
                    }
                }
            }
            return(replaced_in_any_file);
        }
        static private void append_to_config_DECAC(Session session, string key, string value)
        {
            string MINION_CONFIGDIR = MinionConfigurationUtilities.getConfigdDirectoryLocation_DECAC(session);

            insert_value_after_comment_or_end_in_minionconfig_file(session, key, value);
        }