public static void Stop() { Systemctl.Stop(ServiceName1); Systemctl.Stop(ServiceName2); Systemctl.Stop(ServiceName3); ConsoleLogger.Log("[samba] stop"); }
private static bool SetUnitForTunnel(string remoteHost) { var lines = new List <string> { "[Unit]", "Description=ExtUnit, VpnConnection", "", "[Service]", $"ExecStart=/usr/bin/ssh -o Tunnel=ethernet -f -w 1:1 root@{remoteHost} true", "SuccessExitStatus=1 2 3 4 5 6 7 8 9 0", "RemainAfterExit=yes", "Type=oneshot", "", "[Install]", "WantedBy=antd.target" }; var unitName = $"/mnt/cdrom/Units/antd.target.wants/antd-{remoteHost}-vpn.service"; ConsoleLogger.Log(unitName); if (!File.Exists(unitName)) { FileWithAcl.WriteAllLines(unitName, lines, "644", "root", "wheel"); Systemctl.DaemonReload(); } Systemctl.Restart($"antd-{remoteHost}-vpn.service"); return(Systemctl.IsActive($"antd-{remoteHost}-vpn.service")); }
private static void EnableRequiredServices() { Systemctl.Start("systemd-networkd.service"); Systemctl.Start("systemd-resolved.service"); Systemctl.Enable("systemd-networkd.service"); Systemctl.Enable("systemd-resolved.service"); }
public string CreatePrepareUnit(string name, string frameworkDir) { var unitName = $"app-{name.ToLower()}-01-prepare.service".Replace(" ", ""); var fileName = $"{Parameter.AppsUnits}/{unitName}"; if (File.Exists(fileName)) { File.Delete(fileName); } var oldUnitName = $"{Parameter.ApplicativeUnits}/{unitName}"; if (File.Exists(oldUnitName)) { File.Delete(oldUnitName); } var lines = new List <string> { "[Unit]", "Description=External Volume Unit, Application: {name} Prepare Service", $"Before=app-{name.ToLower()}-02-mount.service".Replace(" ", ""), "", "[Service]", $"ExecStart=/bin/mkdir -p {frameworkDir}", "SuccessExitStatus=0", "RemainAfterExit=yes", "", "[Install]", "WantedBy=app.target" }; File.WriteAllLines(fileName, lines); Systemctl.DaemonReload(); return(unitName); }
public string CreateLauncherUnit(string name, string exeName, string exePath) { var unitName = $"app-{name.ToLower()}-{exeName.ToLower().Replace(".exe", "")}-launcher.service"; var fileName = $"{Parameter.AppsUnits}/{unitName}"; if (File.Exists(fileName)) { File.Delete(fileName); } var oldUnitName = $"{Parameter.ApplicativeUnits}/{unitName}"; if (File.Exists(oldUnitName)) { File.Delete(oldUnitName); } var lines = new List <string> { "[Unit]", $"Description=External Volume Unit, Application: {exeName} Launcher Service", $"After=app-{name.ToLower()}-02-mount.service".Replace(" ", ""), "", "[Service]", $"ExecStart=/usr/bin/mono {exePath}", "Restart=on-failure", "RemainAfterExit=no", "TasksMax=infinity", "LimitNOFILE=1024000", "", "[Install]", "WantedBy=app.target" }; File.WriteAllLines(fileName, lines); Systemctl.DaemonReload(); return(unitName); }
public string CreateMountUnit(string name, string sourcePath, string frameworkDir) { var unitName = $"app-{name.ToLower()}-02-mount.service".Replace(" ", ""); var fileName = $"{Parameter.AppsUnits}/{unitName}"; if (File.Exists(fileName)) { File.Delete(fileName); } var oldUnitName = $"{Parameter.ApplicativeUnits}/{unitName}"; if (File.Exists(oldUnitName)) { File.Delete(oldUnitName); } var lines = new List <string> { "[Unit]", $"Description=External Volume Unit, Application: {frameworkDir} Mount", "", "[Service]", $"ExecStart=/bin/mount {sourcePath} {frameworkDir}", "SuccessExitStatus=0", "RemainAfterExit=yes", "", "[Install]", "WantedBy=applicative.target" }; FileWithAcl.WriteAllLines(fileName, lines, "644", "root", "wheel"); Systemctl.DaemonReload(); return(unitName); }
public void Setup() { if (Systemctl.IsEnabled("systemd-networkd.service") == false) { Systemctl.Enable("systemd-networkd.service"); } if (Systemctl.IsActive("systemd-networkd.service") == false) { Systemctl.Start("systemd-networkd.service"); } if (Systemctl.IsEnabled("systemd-resolved.service") == false) { Systemctl.Enable("systemd-resolved.service"); } if (Systemctl.IsActive("systemd-resolved.service") == false) { Systemctl.Start("systemd-resolved.service"); } _bash.Execute("ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf", false); if (!Directory.Exists(NetworkdFolder)) { Directory.CreateDirectory(NetworkdFolder); } }
public static void Start() { if (Systemctl.IsEnabled(ServiceName1) == false) { Systemctl.Enable(ServiceName1); } if (Systemctl.IsActive(ServiceName1) == false) { Systemctl.Restart(ServiceName1); } if (Systemctl.IsEnabled(ServiceName2) == false) { Systemctl.Enable(ServiceName2); } if (Systemctl.IsActive(ServiceName2) == false) { Systemctl.Restart(ServiceName2); } if (Systemctl.IsEnabled(ServiceName3) == false) { Systemctl.Enable(ServiceName3); } if (Systemctl.IsActive(ServiceName3) == false) { Systemctl.Restart(ServiceName3); } ConsoleLogger.Log("[samba] start"); }
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); }; }
private static void Main(string[] args) { DateTime startTime = DateTime.Now; Console.Title = "ANTD"; Console.WriteLine(ConsoleTime.GetTime(DateTime.Now) + "loading application..."); SystemConfig.FirstLaunchDefaults(); Console.WriteLine(ConsoleTime.GetTime(DateTime.Now) + "setting core system configuration..."); Cfg.FirstLaunchDefaults(); Console.WriteLine(ConsoleTime.GetTime(DateTime.Now) + "setting core cfg configuration..."); var stop = new ManualResetEvent(false); Console.CancelKeyPress += (sender, e) => { Console.WriteLine("^C"); Database.ShutDown(); stop.Set(); e.Cancel = true; }; string uri = SelfConfig.GetAntdUri(); Console.WriteLine(ConsoleTime.GetTime(DateTime.Now) + "initializing antd"); using (WebApp.Start <Startup>(uri)) { Console.WriteLine(ConsoleTime.GetTime(DateTime.Now) + "loading service"); Console.WriteLine(ConsoleTime.GetTime(DateTime.Now) + " service type -> server"); Console.WriteLine(ConsoleTime.GetTime(DateTime.Now) + " -> server url -> {0}", uri); Console.WriteLine(ConsoleTime.GetTime(DateTime.Now) + "service is now running"); var elapsed = DateTime.Now - startTime; Console.WriteLine(ConsoleTime.GetTime(DateTime.Now) + "loaded in: " + elapsed); Console.WriteLine(""); ServiceUnitInfo.SetDefaultUnitInfo(); Console.WriteLine(ConsoleTime.GetTime(DateTime.Now) + "misc -> default unit info saved to database"); UnitFile.WriteForSelf(); Console.WriteLine(ConsoleTime.GetTime(DateTime.Now) + "self -> unit file created"); Systemctl.Enable("antd.service"); Console.WriteLine(ConsoleTime.GetTime(DateTime.Now) + "self -> unit file enabled"); //Console.WriteLine(""); //string[] watchThese = new string[] { // "/cfg", // "/proc/sys", // "/sys/class/net" //}; //foreach (string folder in watchThese) { // new DirectoryWatcher(folder).Watch(); // Console.WriteLine(ConsoleTime.GetTime(DateTime.Now) + "watcher enabled for {0}", folder); //} stop.WaitOne(); } }
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 SyncClock(string ntpServer = "") { var launcher = new CommandLauncher(); ApplyNtpdate(); if (Systemctl.IsActive("ntpd")) { ApplyNtpd(); } launcher.Launch("sync-clock"); }
public void Start() { if (Systemctl.IsEnabled(ServiceName) == false) { Systemctl.Enable(ServiceName); } if (Systemctl.IsActive(ServiceName) == false) { Systemctl.Restart(ServiceName); } ConsoleLogger.Log("[kerberos] start"); }
public static void Setup() { if (!Directory.Exists("/mnt/cdrom/Units")) { return; } if (!Directory.Exists("/mnt/cdrom/Units/antd.target.wants")) { return; } var edit = false; if (!File.Exists(Service01PreparePath)) { FileWithAcl.WriteAllLines(Service01PreparePath, Service01Prepare(), "644", "root", "wheel"); edit = true; } if (!File.Exists(Service02MountPath)) { FileWithAcl.WriteAllLines(Service02MountPath, Service02Mount(), "644", "root", "wheel"); edit = true; } if (!File.Exists(Service03LauncherPath)) { FileWithAcl.WriteAllLines(Service03LauncherPath, Service03Launcher(), "644", "root", "wheel"); edit = true; } if (edit) { Systemctl.DaemonReload(); if (Systemctl.IsActive(Service01PrepareUnit) == false) { Systemctl.Restart(Service01PrepareUnit); } if (Systemctl.IsActive(Service02MountUnit) == false) { Systemctl.Restart(Service02MountUnit); } if (Systemctl.IsActive(Service03LauncherUnit) == false) { Systemctl.Restart(Service03LauncherUnit); } } }
public void StartService() { var svcs = HostParametersConfiguration.Conf.ServicesStart; foreach (var svc in svcs) { if (Systemctl.IsEnabled(svc) == false) { Systemctl.Enable(svc); } if (Systemctl.IsActive(svc) == false) { Systemctl.Start(svc); } } }
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 Launch() { ConsoleLogger.Log("[gluster] launch"); var config = ServiceModel; SetHostnameFile(config); Systemctl.Enable(ServiceName); Systemctl.Start(ServiceName); ConsoleLogger.Log("[gluster] include nodes"); foreach (var node in config.Nodes) { IncludeNode(node.Hostname); } ConsoleLogger.Log("[gluster] start volumes"); foreach (var volume in config.Volumes) { SetVolume(volume, config.Nodes); } }
public static void Setup() { var edit = false; if (!File.Exists(Service01PreparePath)) { File.WriteAllLines(Service01PreparePath, Service01Prepare()); edit = true; } if (!File.Exists(Service02MountPath)) { File.WriteAllLines(Service02MountPath, Service02Mount()); edit = true; } if (!File.Exists(Service03LauncherPath)) { File.WriteAllLines(Service03LauncherPath, Service03Launcher()); edit = true; } if (edit) { Systemctl.DaemonReload(); if (Systemctl.IsActive(Service01PrepareUnit) == false) { Systemctl.Restart(Service01PrepareUnit); } if (Systemctl.IsActive(Service02MountUnit) == false) { Systemctl.Restart(Service02MountUnit); } if (Systemctl.IsActive(Service03LauncherUnit) == false) { Systemctl.Restart(Service03LauncherUnit); } } }
public static void SetAnthillaSp() { var path = Name.Prepare; if (!File.Exists(path)) { using (var sw = File.CreateText(path)) { sw.WriteLine("[Unit]"); sw.WriteLine("Description=External Volume Unit, Application: AnthillaSP Prepare Service"); sw.WriteLine("Requires=local-fs.target sysinit.target"); sw.WriteLine("Before=app-anthillasp-02-Mount.service"); sw.WriteLine(""); sw.WriteLine("[Service]"); sw.WriteLine("ExecStart=/bin/mkdir -p /framework/anthillasp"); sw.WriteLine(""); sw.WriteLine("[Install]"); sw.WriteLine("WantedBy=applicative.target"); } } Systemctl.DaemonReload(); }
public static void LaunchAnthillaServer() { var path = Name.LaunchServer; if (!File.Exists(path)) { using (var sw = File.CreateText(path)) { sw.WriteLine("[Unit]"); sw.WriteLine("Description=External Volume Unit, Application: AnthillaServer Launcher Service"); sw.WriteLine("Requires=local-fs.target sysinit.target"); sw.WriteLine("After=app-anthillasp-02-Mount.service"); sw.WriteLine(""); sw.WriteLine("[Service]"); sw.WriteLine("ExecStart=/usr/bin/mono /framework/anthillasp/anthillaserver/AnthillaServer.exe"); sw.WriteLine(""); sw.WriteLine("[Install]"); sw.WriteLine("WantedBy=applicative.target"); } } Systemctl.DaemonReload(); }
public static void MountFramework() { var path = Name.Mount; if (!File.Exists(path)) { using (var sw = File.CreateText(path)) { sw.WriteLine("[Unit]"); sw.WriteLine("Description = ExtUnit, Application: Anthillasp 02 Mount Service"); sw.WriteLine("Before=app-anthillasp-03-srv-launcher.service"); sw.WriteLine(""); sw.WriteLine("[Service]"); sw.WriteLine("ExecStart=/bin/mount /mnt/cdrom/Apps/Anthilla_AnthillaSP/active-version /framework/anthillasp"); sw.WriteLine("SuccessExitStatus=0"); sw.WriteLine("RemainAfterExit=yes"); sw.WriteLine(""); sw.WriteLine("[Install]"); sw.WriteLine("WantedBy=applicative.target"); } } Systemctl.DaemonReload(); }
//public static void CreateUnits() { // if (Units.CheckFiles() == false) { // Units.SetAnthillaSp(); // Units.MountFramework(); // Units.LaunchAnthillaSp(); // Units.LaunchAnthillaServer(); // } // Systemctl.DaemonReload(); //} //private static void SetDirectories() { // var app = Management.DetectApps().FirstOrDefault(a => a.Name == "anthillasp"); // if (app == null) { // ConsoleLogger.Log("no appinfo detected"); // } // else { // var dirs = Management.GetWantedDirectories(app); // if (dirs.Length <= 0) { // ConsoleLogger.Log("no app directory found"); // } // else { // foreach (var dir in dirs) { // Directory.CreateDirectory(dir.Trim()); // Directory.CreateDirectory(Mount.SetDirsPath(dir.Trim())); // Mount.Dir(dir.Trim()); // } // } // } //} public static void Start() { if (!Systemctl.Status("app-anthillasp-01-prepare.service").output.Contains("Active: active (running)")) { Systemctl.Start("app-anthillasp-01-prepare.service"); } if (!Systemctl.Status("app-anthillasp-02-mount.service").output.Contains("Active: active (running)")) { Systemctl.Start("app-anthillasp-02-mount.service"); } if (!Systemctl.Status("app-anthillasp-03-srv-launcher.service").output.Contains("Active: active (running)")) { Systemctl.Start("app-anthillasp-03-srv-launcher.service"); } if (!Systemctl.Status("app-anthillasp-04-wui-launcher.service").output.Contains("Active: active (running)")) { Systemctl.Start("app-anthillasp-04-wui-launcher.service"); } }
private static string StatusNetworkdDir() { var r = Systemctl.Status("systemd-networkd"); return(r.output); }
private static string RestartNetworkdDir() { var r = Systemctl.Restart("systemd-networkd"); return(r.output); }
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 static void Stop() { Systemctl.Stop(ServiceName); ConsoleLogger.Log("[syslogng] stop"); }
public void Stop() { Systemctl.Stop(ServiceName); ConsoleLogger.Log("[kerberos] stop"); }