private static void Action() { var lsmod = Mapper.FromCommand <ModuleModel>("lsmod").ToList().Skip(1).ToList(); if (!lsmod.Any()) { return; } var launcher = new CommandLauncher(); launcher.Launch("rmmod", new Dictionary <string, string> { { "$modules", lsmod.Select(_ => _.Name).JoinToString(" ") } }); var hostConfiguration = new HostConfiguration(); hostConfiguration.ApplyHostModprobes(); }
public BootModulesModule() { Get["/boot/modules"] = x => { var hostcfg = new HostConfiguration(); var model = new PageBootModulesModel { Modules = string.Join(Environment.NewLine, hostcfg.GetHostModprobes()), RmModules = string.Join(Environment.NewLine, hostcfg.GetHostRemoveModules()), Blacklist = string.Join(Environment.NewLine, hostcfg.GetHostBlacklistModules()) }; return(JsonConvert.SerializeObject(model)); }; Post["/boot/modules"] = x => { string modulesText = Request.Form.Config; var modules = modulesText.SplitToList(Environment.NewLine).Where(_ => !string.IsNullOrEmpty(_)); var hostcfg = new HostConfiguration(); hostcfg.SetHostModprobes(modules); hostcfg.ApplyHostModprobes(); return(HttpStatusCode.OK); }; Post["/boot/rmmodules"] = x => { string modulesText = Request.Form.Config; var modules = modulesText.SplitToList(Environment.NewLine).Where(_ => !string.IsNullOrEmpty(_)); var hostcfg = new HostConfiguration(); hostcfg.SetHostRemoveModules(modules); hostcfg.ApplyHostRemoveModules(); return(HttpStatusCode.OK); }; Post["/boot/modblacklist"] = x => { string modulesText = Request.Form.Config; var modules = modulesText.SplitToList(Environment.NewLine).Where(_ => !string.IsNullOrEmpty(_)); var hostcfg = new HostConfiguration(); hostcfg.SetHostBlacklistModules(modules); hostcfg.ApplyHostBlacklistModules(); return(HttpStatusCode.OK); }; }