public static void Stop() { Systemctl.Stop(ServiceName1); Systemctl.Stop(ServiceName2); Systemctl.Stop(ServiceName3); ConsoleLogger.Log("[samba] stop"); }
public UnitsModule() : base("/units") { Get["/"] = x => { List <UnitModel> units = Units.All; return(View["page-units", units]); }; Post["/mgmt/enable/{unit}"] = x => { string unit = x.unit; CommandModel r = Systemctl.Enable(unit); string json = JsonConvert.SerializeObject(r.outputTable); return(json); }; Post["/mgmt/disable/{unit}"] = x => { string unit = x.unit; CommandModel r = Systemctl.Disable(unit); string json = JsonConvert.SerializeObject(r.outputTable); return(json); }; Post["/mgmt/start/{unit}"] = x => { string unit = x.unit; CommandModel r = Systemctl.Start(unit); string json = JsonConvert.SerializeObject(r.outputTable); return(json); }; Post["/mgmt/stop/{unit}"] = x => { string unit = x.unit; CommandModel r = Systemctl.Stop(unit); string json = JsonConvert.SerializeObject(r.outputTable); return(json); }; Post["/mgmt/restart/{unit}"] = x => { string unit = x.unit; CommandModel r = Systemctl.Restart(unit); string json = JsonConvert.SerializeObject(r.outputTable); return(json); }; Post["/mgmt/reload/{unit}"] = x => { string unit = x.unit; CommandModel r = Systemctl.Reload(unit); string json = JsonConvert.SerializeObject(r.outputTable); return(json); }; Get["/mgmt/status/{unit}"] = x => { string unit = x.unit; CommandModel r = Systemctl.Status(unit); string json = JsonConvert.SerializeObject(r.outputTable); return(json); }; }
public AntdServicesModule() { Get["/services"] = x => { var model = new PageServicesModel(); var machineInfo = new MachineInfo(); var services = machineInfo.GetUnits("service"); var mounts = machineInfo.GetUnits("mount"); var targets = machineInfo.GetUnits("target"); var timers = machineInfo.GetUnits("timer"); services.AddRange(mounts); services.AddRange(targets); services.AddRange(timers); model.Units = services; return(JsonConvert.SerializeObject(model)); }; Get["/services/log"] = x => { string unit = Request.Query.unit; var launcher = new CommandLauncher(); var model = launcher.Launch("journactl-service", new Dictionary <string, string> { { "$service", unit } }); return(JsonConvert.SerializeObject(model)); }; Post["/services/start"] = x => { string unit = Request.Form.Unit; Systemctl.Start(unit); return(HttpStatusCode.OK); }; Post["/services/restart"] = x => { string unit = Request.Form.Unit; Systemctl.Restart(unit); return(HttpStatusCode.OK); }; Post["/services/stop"] = x => { string unit = Request.Form.Unit; Systemctl.Stop(unit); return(HttpStatusCode.OK); }; Post["/services/enable"] = x => { string unit = Request.Form.Unit; Systemctl.Enable(unit); return(HttpStatusCode.OK); }; Post["/services/disable"] = x => { string unit = Request.Form.Unit; Systemctl.Disable(unit); return(HttpStatusCode.OK); }; }
public UnitsModule() { this.RequiresAuthentication(); Get["/units"] = x => { var units = Units.All; return(View["page-units", units]); }; Get["/units/list"] = x => { return(JsonConvert.SerializeObject(Units.All.OrderBy(u => u.name))); }; Post["/units/mgmt/enable/{unit}"] = x => { string unit = x.unit; var r = Systemctl.Enable(unit); return(JsonConvert.SerializeObject(r.outputTable)); }; Post["/units/mgmt/disable/{unit}"] = x => { string unit = x.unit; var r = Systemctl.Disable(unit); return(JsonConvert.SerializeObject(r.outputTable)); }; Post["/units/mgmt/start/{unit}"] = x => { string unit = x.unit; var r = Systemctl.Start(unit); return(JsonConvert.SerializeObject(r.outputTable)); }; Post["/units/mgmt/stop/{unit}"] = x => { string unit = x.unit; var r = Systemctl.Stop(unit); return(JsonConvert.SerializeObject(r.outputTable)); }; Post["/units/mgmt/restart/{unit}"] = x => { string unit = x.unit; var r = Systemctl.Restart(unit); return(JsonConvert.SerializeObject(r.outputTable)); }; Post["/units/mgmt/reload/{unit}"] = x => { string unit = x.unit; var r = Systemctl.Reload(unit); return(JsonConvert.SerializeObject(r.outputTable)); }; Get["/units/mgmt/status/{unit}"] = x => { string unit = x.unit; var r = Systemctl.Status(unit); return(JsonConvert.SerializeObject(r.outputTable)); }; }
public void StopService() { var svcs = HostParametersConfiguration.Conf.ServicesStop; foreach (var svc in svcs) { if (Systemctl.IsEnabled(svc)) { Systemctl.Disable(svc); } if (Systemctl.IsActive(svc)) { Systemctl.Stop(svc); } } }
private void SaveKeepalived(string publicIp, List <NodeModel> nodes) { ConsoleLogger.Log("[cluster] init keepalived"); const string keepalivedService = "keepalived.service"; if (Systemctl.IsActive(keepalivedService)) { ConsoleLogger.Log("[cluster] stop service"); Systemctl.Stop(keepalivedService); } ConsoleLogger.Log("[cluster] set configuration file"); var clusterInfo = ClusterConfiguration.GetClusterInfo(); var lines = new List <string> { "vrrp_script chk_haproxy {", " script \"killall -0 haproxy\"", " interval 2", " weight 2", "}", "", "vrrp_instance RH_INT {", $" interface {clusterInfo.NetworkInterface}", " state MASTER", " virtual_router_id 51", $" priority {clusterInfo.Priority}", " virtual_ipaddress {", $" {clusterInfo.VirtualIpAddress}", " }", " track_script {", " chk_haproxy", " }", "}", }; FileWithAcl.WriteAllLines(KeepalivedFileOutput, lines); //if(Systemctl.IsEnabled(keepalivedService) == false) { // Systemctl.Enable(keepalivedService); // ConsoleLogger.Log("[cluster] keepalived enabled"); //} //if(Systemctl.IsActive(keepalivedService) == false) { // Systemctl.Restart(keepalivedService); // ConsoleLogger.Log("[cluster] keepalived restarted"); //} Systemctl.Enable(keepalivedService); ConsoleLogger.Log("[cluster] keepalived enabled"); Systemctl.Restart(keepalivedService); ConsoleLogger.Log("[cluster] keepalived restarted"); }
public AppsManagementModule() { Get["/apps/management"] = x => { var appsConfiguration = new AppsConfiguration(); var model = new PageAppsManagementModel { AppList = appsConfiguration.Get().Apps }; return(JsonConvert.SerializeObject(model)); }; Post["/apps/setup"] = x => { string app = Request.Form.AppName; if (string.IsNullOrEmpty(app)) { return(HttpStatusCode.InternalServerError); } var appsManagement = new AppsManagement(); appsManagement.Setup(app); return(HttpStatusCode.OK); }; Get["/apps/status/{unit}"] = x => { string unitName = x.unit; var status = Systemctl.Status(unitName); return(Response.AsJson(status)); }; Get["/apps/active/{unit}"] = x => { string unitName = x.unit; var status = Systemctl.IsActive(unitName); return(Response.AsJson(status ? "active" : "inactive")); }; Post["/apps/restart"] = x => { string unitName = Request.Form.Name; Systemctl.Restart(unitName); return(HttpStatusCode.OK); }; Post["/apps/stop"] = x => { string unitName = Request.Form.Name; Systemctl.Stop(unitName); return(HttpStatusCode.OK); }; }
public static void Stop() { Systemctl.Stop(ServiceName); ConsoleLogger.Log("[journald] stop"); }
public static void Stop() { Systemctl.Stop(ServiceName); ConsoleLogger.Log("[syslogng] stop"); }
public void Stop() { Systemctl.Stop(ServiceName); ConsoleLogger.Log("[kerberos] stop"); }
public static void Stop() { Systemctl.Stop(ServiceName); ConsoleLogger.Log("[gluster] stop"); }
public static CommandModel StopAnthillaServer() { return(Systemctl.Stop("anthillaserver.service")); }
public static void StopServer() { Systemctl.Stop("app-anthillasp-03-srv-launcher.service"); }
public static void ApplyInterfaceSetting(NetworkInterfaceConfigurationModel model) { var netif = model.Interface; switch (model.Type) { case NetworkAdapterType.Physical: break; case NetworkAdapterType.Virtual: break; case NetworkAdapterType.Bond: CommandLauncher.Launch("bond-set", new Dictionary <string, string> { { "$bond", netif } }); foreach (var nif in model.InterfaceList) { CommandLauncher.Launch("bond-add-if", new Dictionary <string, string> { { "$bond", netif }, { "$net_if", nif } }); } break; case NetworkAdapterType.Bridge: CommandLauncher.Launch("brctl-add", new Dictionary <string, string> { { "$bridge", netif } }); foreach (var nif in model.InterfaceList) { CommandLauncher.Launch("brctl-add-if", new Dictionary <string, string> { { "$bridge", netif }, { "$net_if", nif } }); } break; case NetworkAdapterType.Other: break; } switch (model.Mode) { case NetworkInterfaceMode.Null: return; case NetworkInterfaceMode.Static: var networkdIsActive = Systemctl.IsActive("systemd-networkd"); if (networkdIsActive) { Systemctl.Stop("systemd-networkd"); } CommandLauncher.Launch("dhcpcd-killall"); CommandLauncher.Launch("ip4-flush-configuration", new Dictionary <string, string> { { "$net_if", netif } }); CommandLauncher.Launch("ip4-add-addr", new Dictionary <string, string> { { "$net_if", netif }, { "$address", model.StaticAddress }, { "$range", model.StaticRange } }); if (networkdIsActive) { Systemctl.Start("systemd-networkd"); } break; case NetworkInterfaceMode.Dynamic: CommandLauncher.Launch("dhcpcd", new Dictionary <string, string> { { "$net_if", netif } }); break; default: return; } CommandLauncher.Launch("ip4-set-mtu", new Dictionary <string, string> { { "$net_if", netif }, { "$mtu", model.Mtu } }); CommandLauncher.Launch("ip4-set-txqueuelen", new Dictionary <string, string> { { "$net_if", netif }, { "$txqueuelen", model.Txqueuelen } }); if (!string.IsNullOrEmpty(model.Route) && !string.IsNullOrEmpty(model.Gateway)) { CommandLauncher.Launch("ip4-add-route", new Dictionary <string, string> { { "$net_if", netif }, { "$gateway", model.Gateway }, { "$ip_address", model.Route } }); } var status = model.Status; switch (status) { case NetworkInterfaceStatus.Down: CommandLauncher.Launch("ip4-disable-if", new Dictionary <string, string> { { "$net_if", netif } }); break; case NetworkInterfaceStatus.Up: CommandLauncher.Launch("ip4-enable-if", new Dictionary <string, string> { { "$net_if", netif } }); ConsoleLogger.Log($"[network] interface '{model.Interface}' configured"); break; default: CommandLauncher.Launch("ip4-disable-if", new Dictionary <string, string> { { "$net_if", netif } }); break; } }
public static void StopSp() { Systemctl.Stop("app-anthillasp-04-wui-launcher.service"); }
public AppsModule() : base("/apps") { this.RequiresAuthentication(); Get["/"] = x => { return(View["_page-apps"]); }; Get["/launch"] = x => { ConsoleLogger.Log(">> App >> AnthillaSP"); ConsoleLogger.Log(">> Check squashfs"); var b = AnthillaSP.Setting.CheckSquash(); if (b == false) { ConsoleLogger.Warn(">> Squashfs does not exist!"); return(Response.AsJson(b)); } else { ConsoleLogger.Log(">> Mount squashfs in /framework/anthillasp"); AnthillaSP.Setting.MountSquash(); ConsoleLogger.Log(">> Create AnthillaSP units in /mnt/cdrom/Overlay/anthillasp/"); AnthillaSP.Setting.CreateUnits(); return(Response.AsJson(true)); } }; Get["/start/sp"] = x => { var start = Command.Launch("mono", "/framework/anthillasp/anthillasp/AnthillaSP.exe &").output; return(Response.AsJson(start)); }; Get["/start/server"] = x => { var start = Command.Launch("mono", "/framework/anthillasp/anthillaserver/AnthillaServer.exe &").output; return(Response.AsJson(start)); }; //Get["/start/sp"] = x => { // var start = Systemctl.Start("anthillasp-launcher.service"); // return Response.AsJson(start); //}; //Get["/start/server"] = x => { // var start = Systemctl.Start("anthillaserver-launcher.service"); // return Response.AsJson(start); //}; Get["/stop/sp"] = x => { var stop = Systemctl.Stop("anthillasp-launcher.service"); return(Response.AsJson(stop)); }; Get["/stop/server"] = x => { var stop = Systemctl.Stop("anthillaserver-launcher.service"); return(Response.AsJson(stop)); }; Get["/status/sp"] = x => { var status = Systemctl.Status("anthillasp-launcher.service"); return(Response.AsJson(status)); }; Get["/status/server"] = x => { var status = Systemctl.Status("anthillaserver-launcher.service"); return(Response.AsJson(status)); }; }
public static CommandModel StopAnthillaStorage() { return(Systemctl.Stop("anthillastorage.service")); }
public static CommandModel StopAnthillaAS() { return(Systemctl.Stop("anthillaas.service")); }
public static CommandModel StopAnthillaFirewall() { return(Systemctl.Stop("anthillafirewall.service")); }
private void SetInterface(NetworkInterface configuration, NetworkInterfaceConfiguration interfaceConfiguration, NetworkGatewayConfiguration gatewayConfiguration) { if (interfaceConfiguration == null) { return; } var deviceName = configuration.Device; var nAt = NetworkAdapterType.Other; if (Network2Configuration.InterfacePhysical.Contains(deviceName)) { nAt = NetworkAdapterType.Physical; } else if (Network2Configuration.InterfaceBridge.Contains(deviceName)) { nAt = NetworkAdapterType.Bridge; } else if (Network2Configuration.InterfaceBond.Contains(deviceName)) { nAt = NetworkAdapterType.Bond; } else if (Network2Configuration.InterfaceVirtual.Contains(deviceName)) { nAt = NetworkAdapterType.Virtual; } switch (nAt) { case NetworkAdapterType.Physical: break; case NetworkAdapterType.Virtual: break; case NetworkAdapterType.Bond: CommandLauncher.Launch("bond-set", new Dictionary <string, string> { { "$bond", deviceName } }); foreach (var nif in interfaceConfiguration.ChildrenIf) { CommandLauncher.Launch("bond-add-if", new Dictionary <string, string> { { "$bond", deviceName }, { "$net_if", nif } }); CommandLauncher.Launch("ip4-flush-configuration", new Dictionary <string, string> { { "$net_if", nif } }); CommandLauncher.Launch("ip4-enable-if", new Dictionary <string, string> { { "$net_if", nif } }); } break; case NetworkAdapterType.Bridge: CommandLauncher.Launch("brctl-add", new Dictionary <string, string> { { "$bridge", deviceName } }); foreach (var nif in interfaceConfiguration.ChildrenIf) { CommandLauncher.Launch("brctl-add-if", new Dictionary <string, string> { { "$bridge", deviceName }, { "$net_if", nif } }); CommandLauncher.Launch("ip4-flush-configuration", new Dictionary <string, string> { { "$net_if", nif } }); CommandLauncher.Launch("ip4-enable-if", new Dictionary <string, string> { { "$net_if", nif } }); } break; case NetworkAdapterType.Other: return; } CommandLauncher.Launch("ip4-set-mtu", new Dictionary <string, string> { { "$net_if", deviceName }, { "$mtu", "6000" } }); CommandLauncher.Launch("ip4-set-txqueuelen", new Dictionary <string, string> { { "$net_if", deviceName }, { "$txqueuelen", "10000" } }); CommandLauncher.Launch("ip4-promisc-on", new Dictionary <string, string> { { "$net_if", deviceName } }); switch (interfaceConfiguration.Mode) { case NetworkInterfaceMode.Null: return; case NetworkInterfaceMode.Static: var networkdIsActive = Systemctl.IsActive("systemd-networkd"); if (networkdIsActive) { Systemctl.Stop("systemd-networkd"); } CommandLauncher.Launch("dhcpcd-killall"); CommandLauncher.Launch("ip4-flush-configuration", new Dictionary <string, string> { { "$net_if", deviceName } }); CommandLauncher.Launch("ip4-add-addr", new Dictionary <string, string> { { "$net_if", deviceName }, { "$address", interfaceConfiguration.Ip }, { "$range", interfaceConfiguration.Subnet } }); if (networkdIsActive) { Systemctl.Start("systemd-networkd"); } break; case NetworkInterfaceMode.Dynamic: CommandLauncher.Launch("dhcpcd", new Dictionary <string, string> { { "$net_if", deviceName } }); break; default: return; } switch (configuration.Status) { case NetworkInterfaceStatus.Down: CommandLauncher.Launch("ip4-disable-if", new Dictionary <string, string> { { "$net_if", deviceName } }); return; case NetworkInterfaceStatus.Up: CommandLauncher.Launch("ip4-enable-if", new Dictionary <string, string> { { "$net_if", deviceName } }); ConsoleLogger.Log($"[network] interface '{deviceName}' configured"); break; default: CommandLauncher.Launch("ip4-disable-if", new Dictionary <string, string> { { "$net_if", deviceName } }); return; } if (gatewayConfiguration == null) { return; } CommandLauncher.Launch("ip4-add-route", new Dictionary <string, string> { { "$net_if", deviceName }, { "$ip_address", "default" }, { "$gateway", gatewayConfiguration.GatewayAddress } }); }
public void Stop() { Systemctl.Stop(ServiceName); ConsoleLogger.Log("[dhcpd] stop"); }