public static void Save(JournaldConfigurationModel model) { var text = JsonConvert.SerializeObject(model, Formatting.Indented); FileWithAcl.WriteAllText(CfgFile, text, "644", "root", "wheel"); ConsoleLogger.Log("[journald] configuration saved"); }
public void Save(JournaldConfigurationModel model) { var text = JsonConvert.SerializeObject(model, Formatting.Indented); if (File.Exists(_cfgFile)) { File.Copy(_cfgFile, _cfgFileBackup, true); } File.WriteAllText(_cfgFile, text); ConsoleLogger.Log("[journald] configuration saved"); }
public JournaldConfiguration() { IoDir.CreateDirectory(Parameter.AntdCfgServices); if (!File.Exists(_cfgFile)) { _serviceModel = new JournaldConfigurationModel(); } else { try { var text = File.ReadAllText(_cfgFile); var obj = JsonConvert.DeserializeObject <JournaldConfigurationModel>(text); _serviceModel = obj; } catch (Exception) { _serviceModel = new JournaldConfigurationModel(); } } }
public LogJournaldModule() { Get["/journald"] = x => { var journaldConfiguration = new JournaldConfiguration(); var journaldIsActive = journaldConfiguration.IsActive(); var model = new PageJournaldModel { JournaldIsActive = journaldIsActive, JournaldOptions = journaldConfiguration.Get() ?? new JournaldConfigurationModel() }; return(JsonConvert.SerializeObject(model)); }; Post["/journald/set"] = x => { var journaldConfiguration = new JournaldConfiguration(); journaldConfiguration.Set(); return(HttpStatusCode.OK); }; Post["/journald/restart"] = x => { var journaldConfiguration = new JournaldConfiguration(); journaldConfiguration.Start(); return(HttpStatusCode.OK); }; Post["/journald/stop"] = x => { var journaldConfiguration = new JournaldConfiguration(); journaldConfiguration.Stop(); return(HttpStatusCode.OK); }; Post["/journald/enable"] = x => { var dhcpdConfiguration = new JournaldConfiguration(); dhcpdConfiguration.Enable(); dhcpdConfiguration.Start(); return(HttpStatusCode.OK); }; Post["/journald/disable"] = x => { var dhcpdConfiguration = new JournaldConfiguration(); dhcpdConfiguration.Disable(); dhcpdConfiguration.Stop(); return(HttpStatusCode.OK); }; Post["/journald/options"] = x => { string storage = Request.Form.Storage; string compress = Request.Form.Compress; string seal = Request.Form.Seal; string splitMode = Request.Form.SplitMode; string syncIntervalSec = Request.Form.SyncIntervalSec; string rateLimitInterval = Request.Form.RateLimitInterval; string rateLimitBurst = Request.Form.RateLimitBurst; string systemMaxUse = Request.Form.SystemMaxUse; string systemKeepFree = Request.Form.SystemKeepFree; string systemMaxFileSize = Request.Form.SystemMaxFileSize; string runtimeMaxUse = Request.Form.RuntimeMaxUse; string runtimeKeepFree = Request.Form.RuntimeKeepFree; string runtimeMaxFileSize = Request.Form.RuntimeMaxFileSize; string maxRetentionSec = Request.Form.MaxRetentionSec; string maxFileSec = Request.Form.MaxFileSec; string forwardToSyslog = Request.Form.ForwardToSyslog; string forwardToKMsg = Request.Form.ForwardToKMsg; string forwardToConsole = Request.Form.ForwardToConsole; string forwardToWall = Request.Form.ForwardToWall; string ttyPath = Request.Form.TTYPath; string maxLevelStore = Request.Form.MaxLevelStore; string maxLevelSyslog = Request.Form.MaxLevelSyslog; string maxLevelKMsg = Request.Form.MaxLevelKMsg; string maxLevelConsole = Request.Form.MaxLevelConsole; string maxLevelWall = Request.Form.MaxLevelWall; var model = new JournaldConfigurationModel { Storage = storage, Compress = compress, Seal = seal, SplitMode = splitMode, SyncIntervalSec = syncIntervalSec, RateLimitInterval = rateLimitInterval, RateLimitBurst = rateLimitBurst, SystemMaxUse = systemMaxUse, SystemKeepFree = systemKeepFree, SystemMaxFileSize = systemMaxFileSize, RuntimeMaxUse = runtimeMaxUse, RuntimeKeepFree = runtimeKeepFree, RuntimeMaxFileSize = runtimeMaxFileSize, MaxRetentionSec = maxRetentionSec, MaxFileSec = maxFileSec, ForwardToSyslog = forwardToSyslog, ForwardToKMsg = forwardToKMsg, ForwardToConsole = forwardToConsole, ForwardToWall = forwardToWall, TtyPath = ttyPath, MaxLevelStore = maxLevelStore, MaxLevelSyslog = maxLevelSyslog, MaxLevelKMsg = maxLevelKMsg, MaxLevelConsole = maxLevelConsole, MaxLevelWall = maxLevelWall, }; var journaldConfiguration = new JournaldConfiguration(); journaldConfiguration.Save(model); return(HttpStatusCode.OK); }; }