void LoadConfig() { IniReader config = IniReader.FromLocation(RootLocation.AllUserConfig); #region HOST NAME m_MyHostName = config.ReadSetting("HOST", "NAME"); if (string.IsNullOrEmpty(m_MyHostName)) { m_MyHostName = NetTools.HostName; this.LogInfo("[HOST] NAME setting not set, using " + m_MyHostName); } #endregion #region MAIL string server = config.ReadSetting("MAIL", "SERVER"); m_MailSender = config.ReadSetting("MAIL", "SENDER"); if (string.IsNullOrEmpty(server)) { server = "localhost"; } m_SmtpClient = new SmtpClient(server); string username = config.ReadSetting("MAIL", "USERNAME"); string password = config.ReadSetting("MAIL", "PASSWORD"); if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) { m_SmtpClient.Credentials = new NetworkCredential(username, password); } m_Greeting = string.Join("\r\n", config.ReadSection("GREETING", false)); #endregion #region DB CONNECTION string connectionString = config.ReadSetting("IMSCP", "CONNECTION"); m_DnsDB = new DynDnsDB(connectionString); this.LogInfo("Connected to database"); #endregion #region PORT string portString = config.ReadSetting("HOST", "PORT"); if (!int.TryParse(portString, out int port) || (port < 0)) { port = 8246; } m_Server.ClientAccepted += ClientAccepted;; m_Server.Listen(port); this.LogInfo("Listening at " + m_Server.LocalEndPoint + " for dynamic updates..."); #endregion }
static bool FindProgramUnix(string name, string description, out string command) { if (m_Cache.TryGetValue(name, out command)) { return(true); } IniReader reader = IniReader.FromLocation(RootLocation.LocalUserConfig); command = reader.ReadSetting("Software", name); if (command != null && File.Exists(command)) { if (!m_Arguments.IsOptionPresent("reset-toolchain")) { m_Cache[name] = command; return(true); } } SystemConsole.WriteLine("\n<yellow>Warning:<default> Build tool <yellow>{0}<default> not set, searching...", description); ProcessResult result = ProcessRunner.Run("whereis", name); if (result.ExitCode != 0) { SystemConsole.WriteLine("<red>Cannot find program {0} with whereis!", name); SystemConsole.WriteLine(result.Combined); return(false); } command = result.StdOut.GetString(-1, ": ", " "); SystemConsole.Write("Selected <cyan>{0}<default> for <cyan>{1}<default>...", command, description); result = ProcessRunner.Run(command, ""); if (result.StartException != null) { SystemConsole.WriteLine(" <red>error"); SystemConsole.WriteLine(result.Combined); return(false); } SystemConsole.WriteLine(" <green>ok"); m_Cache[name] = command; IniWriter writer = new IniWriter(reader); writer.WriteSetting("Software", name, command); writer.Save(); return(true); }